<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rarora4</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rarora4"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Rarora4"/>
	<updated>2026-08-07T16:13:40Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91166</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91166"/>
		<updated>2014-10-30T02:25:33Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Known Issues and Proposed Future Work */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
[http://guides.rubyonrails.org/action_mailer_basics.html Action Mailer] supports email functionality within a Rails application, which involves sending and receiving emails from and to an application. The scope of the Action Mailer within Expertiza is limited to sending emails only which we have proposed to extend to 'Receiving' under the heading ‘Future Work’.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
===Problem Definition===&lt;br /&gt;
Design strategy has been one of the major issue for erratic behavior of Mailer within Expertiza. From past few years the Expertiza has been combined with various enhancements and the code has been changed by different teams, the difference in the implementation practices has introduced major design flaws within some components (including Mailer) of the application. Another major issue is the migration issue from Rails 3 to Rails 4 as a result of which many of the unsupported features for Rails 4 have stopped working.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
The aim of this Mailer project is to bring consistency in the design implementation and restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. High-level requirements are listed below:&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
== Mailer in Expertiza==&lt;br /&gt;
&lt;br /&gt;
===Type of Mailers===&lt;br /&gt;
Expertiza has two different Mailer implementations based on type of events: Synchronous events and Asynchronous events. The synchronous events refer to events that should be immediately notified. For example, email should be sent immediately after a review; or after a feedback of the review has been posted; or a user/team is assigned a project, or a social bookmark have been added, etc. Asynchronous Events are a series of timed events which gets triggered at some fixed times, such as weekly quiz reminders, deadline approaching reminders or in fact Sign Up topic availability reminder is a very explanatory example of Asynchronous Events.&lt;br /&gt;
&lt;br /&gt;
Below mentioned are the changes made in each of the Mailer implementation and in related files.&lt;br /&gt;
&lt;br /&gt;
===Synchronous Mailer and Issues===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Mailer and Issues===&lt;br /&gt;
&lt;br /&gt;
The asynchronous mailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
==Other Issues Addressed==&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
Each due date for submission, review, meta review, sign up, and drop topic were missing under the Assignment edit page due to the bugs in its views and partials files. The JavaScript implementation was previously done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation for Reviewers==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known issues and Proposed Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidentally changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
7. Extending Expertiza's scope to include 'Receive' email functionality.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91128</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91128"/>
		<updated>2014-10-30T01:46:35Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Known Issues and Future Work */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
[http://guides.rubyonrails.org/action_mailer_basics.html Action Mailer] supports email functionality within a Rails application, which involves sending and receiving emails from and to an application. The scope of the Action Mailer within Expertiza is limited to sending emails only which we have proposed to extend to 'Receiving' under the heading ‘Future Work’.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
===Problem Definition===&lt;br /&gt;
Design strategy has been one of the major issue for erratic behavior of Mailer within Expertiza. From past few years the Expertiza has been combined with various enhancements and the code has been changed by different teams, the difference in the implementation practices has introduced major design flaws within some components (including Mailer) of the application. Another major issue is the migration issue from Rails 3 to Rails 4 as a result of which many of the unsupported features for Rails 4 have stopped working.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
The aim of this Mailer project is to bring consistency in the design implementation and restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. High-level requirements are listed below:&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
== Mailer in Expertiza==&lt;br /&gt;
&lt;br /&gt;
===Type of Mailers===&lt;br /&gt;
Expertiza has two different Mailer implementations based on type of events: Synchronous events and Asynchronous events. The synchronous events refer to events that should be immediately notified. For example, email should be sent immediately after a review; or after a feedback of the review has been posted; or a user/team is assigned a project, or a social bookmark have been added, etc. Asynchronous Events are a series of timed events which gets triggered at some fixed times, such as weekly quiz reminders, deadline approaching reminders or in fact Sign Up topic availability reminder is a very explanatory example of Asynchronous Events.&lt;br /&gt;
&lt;br /&gt;
Below mentioned are the changes made in each of the Mailer implementation and in related files.&lt;br /&gt;
&lt;br /&gt;
===Synchronous Mailer and Issues===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Mailer and Issues===&lt;br /&gt;
&lt;br /&gt;
The asynchronous mailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
==Other Issues Addressed==&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
Each due date for submission, review, meta review, sign up, and drop topic were missing under the Assignment edit page due to the bugs in its views and partials files. The JavaScript implementation was previously done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation for Reviewers==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Proposed Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidentally changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
7. Extending Expertiza's scope to include 'Receive' email functionality.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91124</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91124"/>
		<updated>2014-10-30T01:44:17Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
[http://guides.rubyonrails.org/action_mailer_basics.html Action Mailer] supports email functionality within a Rails application, which involves sending and receiving emails from and to an application. The scope of the Action Mailer within Expertiza is limited to sending emails only which we have proposed to extend to 'Receiving' under the heading ‘Future Work’.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
===Problem Definition===&lt;br /&gt;
Design strategy has been one of the major issue for erratic behavior of Mailer within Expertiza. From past few years the Expertiza has been combined with various enhancements and the code has been changed by different teams, the difference in the implementation practices has introduced major design flaws within some components (including Mailer) of the application. Another major issue is the migration issue from Rails 3 to Rails 4 as a result of which many of the unsupported features for Rails 4 have stopped working.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
The aim of this Mailer project is to bring consistency in the design implementation and restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. High-level requirements are listed below:&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
== Mailer in Expertiza==&lt;br /&gt;
&lt;br /&gt;
===Type of Mailers===&lt;br /&gt;
Expertiza has two different Mailer implementations based on type of events: Synchronous events and Asynchronous events. The synchronous events refer to events that should be immediately notified. For example, email should be sent immediately after a review; or after a feedback of the review has been posted; or a user/team is assigned a project, or a social bookmark have been added, etc. Asynchronous Events are a series of timed events which gets triggered at some fixed times, such as weekly quiz reminders, deadline approaching reminders or in fact Sign Up topic availability reminder is a very explanatory example of Asynchronous Events.&lt;br /&gt;
&lt;br /&gt;
Below mentioned are the changes made in each of the Mailer implementation and in related files.&lt;br /&gt;
&lt;br /&gt;
===Synchronous Mailer and Issues===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Mailer and Issues===&lt;br /&gt;
&lt;br /&gt;
The asynchronous mailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
==Other Issues Addressed==&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
Each due date for submission, review, meta review, sign up, and drop topic were missing under the Assignment edit page due to the bugs in its views and partials files. The JavaScript implementation was previously done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation for Reviewers==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91123</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91123"/>
		<updated>2014-10-30T01:43:36Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Other Issues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
[http://guides.rubyonrails.org/action_mailer_basics.html Action Mailer] supports email functionality within a Rails application, which involves sending and receiving emails from and to an application. The scope of the Action Mailer within Expertiza is limited to sending emails only which we have proposed to extend to 'Receiving' under the heading ‘Future Work’.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
===Problem Definition===&lt;br /&gt;
Design strategy has been one of the major issue for erratic behavior of Mailer within Expertiza. From past few years the Expertiza has been combined with various enhancements and the code has been changed by different teams, the difference in the implementation practices has introduced major design flaws within some components (including Mailer) of the application. Another major issue is the migration issue from Rails 3 to Rails 4 as a result of which many of the unsupported features for Rails 4 have stopped working.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
The aim of this Mailer project is to bring consistency in the design implementation and restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. High-level requirements are listed below:&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
== Mailer in Expertiza==&lt;br /&gt;
&lt;br /&gt;
===Type of Mailers===&lt;br /&gt;
Expertiza has two different Mailer implementations based on type of events: Synchronous events and Asynchronous events. The synchronous events refer to events that should be immediately notified. For example, email should be sent immediately after a review; or after a feedback of the review has been posted; or a user/team is assigned a project, or a social bookmark have been added, etc. Asynchronous Events are a series of timed events which gets triggered at some fixed times, such as weekly quiz reminders, deadline approaching reminders or in fact Sign Up topic availability reminder is a very explanatory example of Asynchronous Events.&lt;br /&gt;
&lt;br /&gt;
Below mentioned are the changes made in each of the Mailer implementation and in related files.&lt;br /&gt;
&lt;br /&gt;
===Synchronous Mailer and Issues===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Mailer and Issues===&lt;br /&gt;
&lt;br /&gt;
The asynchronous mailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
==Other Issues Addressed==&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
Each due date for submission, review, meta review, sign up, and drop topic were missing under the Assignment edit page due to the bugs in its views and partials files. The JavaScript implementation was previously done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91118</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91118"/>
		<updated>2014-10-30T01:39:49Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Installation Steps to check Mailer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
[http://guides.rubyonrails.org/action_mailer_basics.html Action Mailer] supports email functionality within a Rails application, which involves sending and receiving emails from and to an application. The scope of the Action Mailer within Expertiza is limited to sending emails only which we have proposed to extend to 'Receiving' under the heading ‘Future Work’.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
===Problem Definition===&lt;br /&gt;
Design strategy has been one of the major issue for erratic behavior of Mailer within Expertiza. From past few years the Expertiza has been combined with various enhancements and the code has been changed by different teams, the difference in the implementation practices has introduced major design flaws within some components (including Mailer) of the application. Another major issue is the migration issue from Rails 3 to Rails 4 as a result of which many of the unsupported features for Rails 4 have stopped working.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
The aim of this Mailer project is to bring consistency in the design implementation and restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. High-level requirements are listed below:&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
== Mailer in Expertiza==&lt;br /&gt;
&lt;br /&gt;
===Type of Mailers===&lt;br /&gt;
Expertiza has two different Mailer implementations based on type of events: Synchronous events and Asynchronous events. The synchronous events refer to events that should be immediately notified. For example, email should be sent immediately after a review; or after a feedback of the review has been posted; or a user/team is assigned a project, or a social bookmark have been added, etc. Asynchronous Events are a series of timed events which gets triggered at some fixed times, such as weekly quiz reminders, deadline approaching reminders or in fact Sign Up topic availability reminder is a very explanatory example of Asynchronous Events.&lt;br /&gt;
&lt;br /&gt;
Below mentioned are the changes made in each of the Mailer implementation and in related files.&lt;br /&gt;
&lt;br /&gt;
===Synchronous Mailer and Issues===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Mailer and Issues===&lt;br /&gt;
&lt;br /&gt;
The asynchronous mailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
==Other Issues==&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
Each due date for submission, review, meta review, sign up, and drop topic were missing under the Assignment edit page due to the bugs in its views and partials files. The JavaScript implementation was previously done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91112</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91112"/>
		<updated>2014-10-30T01:37:23Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Asynchronous and Issues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
[http://guides.rubyonrails.org/action_mailer_basics.html Action Mailer] supports email functionality within a Rails application, which involves sending and receiving emails from and to an application. The scope of the Action Mailer within Expertiza is limited to sending emails only which we have proposed to extend to 'Receiving' under the heading ‘Future Work’.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
===Problem Definition===&lt;br /&gt;
Design strategy has been one of the major issue for erratic behavior of Mailer within Expertiza. From past few years the Expertiza has been combined with various enhancements and the code has been changed by different teams, the difference in the implementation practices has introduced major design flaws within some components (including Mailer) of the application. Another major issue is the migration issue from Rails 3 to Rails 4 as a result of which many of the unsupported features for Rails 4 have stopped working.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
The aim of this Mailer project is to bring consistency in the design implementation and restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. High-level requirements are listed below:&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
== Mailer in Expertiza==&lt;br /&gt;
&lt;br /&gt;
===Type of Mailers===&lt;br /&gt;
Expertiza has two different Mailer implementations based on type of events: Synchronous events and Asynchronous events. The synchronous events refer to events that should be immediately notified. For example, email should be sent immediately after a review; or after a feedback of the review has been posted; or a user/team is assigned a project, or a social bookmark have been added, etc. Asynchronous Events are a series of timed events which gets triggered at some fixed times, such as weekly quiz reminders, deadline approaching reminders or in fact Sign Up topic availability reminder is a very explanatory example of Asynchronous Events.&lt;br /&gt;
&lt;br /&gt;
Below mentioned are the changes made in each of the Mailer implementation and in related files.&lt;br /&gt;
&lt;br /&gt;
===Synchronous Mailer and Issues===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Mailer and Issues===&lt;br /&gt;
&lt;br /&gt;
The asynchronous mailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
==Other Issues==&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
Each due date for submission, review, meta review, sign up, and drop topic were missing under the Assignment edit page due to the bugs in its views and partials files. The JavaScript implementation was previously done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation Steps to check Mailer==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91111</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91111"/>
		<updated>2014-10-30T01:36:54Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Asynchronous Emailer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
[http://guides.rubyonrails.org/action_mailer_basics.html Action Mailer] supports email functionality within a Rails application, which involves sending and receiving emails from and to an application. The scope of the Action Mailer within Expertiza is limited to sending emails only which we have proposed to extend to 'Receiving' under the heading ‘Future Work’.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
===Problem Definition===&lt;br /&gt;
Design strategy has been one of the major issue for erratic behavior of Mailer within Expertiza. From past few years the Expertiza has been combined with various enhancements and the code has been changed by different teams, the difference in the implementation practices has introduced major design flaws within some components (including Mailer) of the application. Another major issue is the migration issue from Rails 3 to Rails 4 as a result of which many of the unsupported features for Rails 4 have stopped working.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
The aim of this Mailer project is to bring consistency in the design implementation and restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. High-level requirements are listed below:&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
== Mailer in Expertiza==&lt;br /&gt;
&lt;br /&gt;
===Type of Mailers===&lt;br /&gt;
Expertiza has two different Mailer implementations based on type of events: Synchronous events and Asynchronous events. The synchronous events refer to events that should be immediately notified. For example, email should be sent immediately after a review; or after a feedback of the review has been posted; or a user/team is assigned a project, or a social bookmark have been added, etc. Asynchronous Events are a series of timed events which gets triggered at some fixed times, such as weekly quiz reminders, deadline approaching reminders or in fact Sign Up topic availability reminder is a very explanatory example of Asynchronous Events.&lt;br /&gt;
&lt;br /&gt;
Below mentioned are the changes made in each of the Mailer implementation and in related files.&lt;br /&gt;
&lt;br /&gt;
===Synchronous Mailer and Issues===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous and Issues===&lt;br /&gt;
&lt;br /&gt;
The asynchronous emailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
==Other Issues==&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
Each due date for submission, review, meta review, sign up, and drop topic were missing under the Assignment edit page due to the bugs in its views and partials files. The JavaScript implementation was previously done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation Steps to check Mailer==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91110</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91110"/>
		<updated>2014-10-30T01:36:42Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Synchronous Emailer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
[http://guides.rubyonrails.org/action_mailer_basics.html Action Mailer] supports email functionality within a Rails application, which involves sending and receiving emails from and to an application. The scope of the Action Mailer within Expertiza is limited to sending emails only which we have proposed to extend to 'Receiving' under the heading ‘Future Work’.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
===Problem Definition===&lt;br /&gt;
Design strategy has been one of the major issue for erratic behavior of Mailer within Expertiza. From past few years the Expertiza has been combined with various enhancements and the code has been changed by different teams, the difference in the implementation practices has introduced major design flaws within some components (including Mailer) of the application. Another major issue is the migration issue from Rails 3 to Rails 4 as a result of which many of the unsupported features for Rails 4 have stopped working.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
The aim of this Mailer project is to bring consistency in the design implementation and restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. High-level requirements are listed below:&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
== Mailer in Expertiza==&lt;br /&gt;
&lt;br /&gt;
===Type of Mailers===&lt;br /&gt;
Expertiza has two different Mailer implementations based on type of events: Synchronous events and Asynchronous events. The synchronous events refer to events that should be immediately notified. For example, email should be sent immediately after a review; or after a feedback of the review has been posted; or a user/team is assigned a project, or a social bookmark have been added, etc. Asynchronous Events are a series of timed events which gets triggered at some fixed times, such as weekly quiz reminders, deadline approaching reminders or in fact Sign Up topic availability reminder is a very explanatory example of Asynchronous Events.&lt;br /&gt;
&lt;br /&gt;
Below mentioned are the changes made in each of the Mailer implementation and in related files.&lt;br /&gt;
&lt;br /&gt;
===Synchronous Mailer and Issues===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
The asynchronous emailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
==Other Issues==&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
Each due date for submission, review, meta review, sign up, and drop topic were missing under the Assignment edit page due to the bugs in its views and partials files. The JavaScript implementation was previously done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation Steps to check Mailer==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91109</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91109"/>
		<updated>2014-10-30T01:35:33Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Other Issues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
[http://guides.rubyonrails.org/action_mailer_basics.html Action Mailer] supports email functionality within a Rails application, which involves sending and receiving emails from and to an application. The scope of the Action Mailer within Expertiza is limited to sending emails only which we have proposed to extend to 'Receiving' under the heading ‘Future Work’.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
===Problem Definition===&lt;br /&gt;
Design strategy has been one of the major issue for erratic behavior of Mailer within Expertiza. From past few years the Expertiza has been combined with various enhancements and the code has been changed by different teams, the difference in the implementation practices has introduced major design flaws within some components (including Mailer) of the application. Another major issue is the migration issue from Rails 3 to Rails 4 as a result of which many of the unsupported features for Rails 4 have stopped working.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
The aim of this Mailer project is to bring consistency in the design implementation and restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. High-level requirements are listed below:&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
== Mailer in Expertiza==&lt;br /&gt;
&lt;br /&gt;
===Type of Mailers===&lt;br /&gt;
Expertiza has two different Mailer implementations based on type of events: Synchronous events and Asynchronous events. The synchronous events refer to events that should be immediately notified. For example, email should be sent immediately after a review; or after a feedback of the review has been posted; or a user/team is assigned a project, or a social bookmark have been added, etc. Asynchronous Events are a series of timed events which gets triggered at some fixed times, such as weekly quiz reminders, deadline approaching reminders or in fact Sign Up topic availability reminder is a very explanatory example of Asynchronous Events.&lt;br /&gt;
&lt;br /&gt;
Below mentioned are the changes made in each of the Mailer implementation and in related files.&lt;br /&gt;
&lt;br /&gt;
===Synchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
The asynchronous emailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
==Other Issues==&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
Each due date for submission, review, meta review, sign up, and drop topic were missing under the Assignment edit page due to the bugs in its views and partials files. The JavaScript implementation was previously done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation Steps to check Mailer==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91108</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91108"/>
		<updated>2014-10-30T01:35:19Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Mailer in Expertiza */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
[http://guides.rubyonrails.org/action_mailer_basics.html Action Mailer] supports email functionality within a Rails application, which involves sending and receiving emails from and to an application. The scope of the Action Mailer within Expertiza is limited to sending emails only which we have proposed to extend to 'Receiving' under the heading ‘Future Work’.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
===Problem Definition===&lt;br /&gt;
Design strategy has been one of the major issue for erratic behavior of Mailer within Expertiza. From past few years the Expertiza has been combined with various enhancements and the code has been changed by different teams, the difference in the implementation practices has introduced major design flaws within some components (including Mailer) of the application. Another major issue is the migration issue from Rails 3 to Rails 4 as a result of which many of the unsupported features for Rails 4 have stopped working.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
The aim of this Mailer project is to bring consistency in the design implementation and restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. High-level requirements are listed below:&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
== Mailer in Expertiza==&lt;br /&gt;
&lt;br /&gt;
===Type of Mailers===&lt;br /&gt;
Expertiza has two different Mailer implementations based on type of events: Synchronous events and Asynchronous events. The synchronous events refer to events that should be immediately notified. For example, email should be sent immediately after a review; or after a feedback of the review has been posted; or a user/team is assigned a project, or a social bookmark have been added, etc. Asynchronous Events are a series of timed events which gets triggered at some fixed times, such as weekly quiz reminders, deadline approaching reminders or in fact Sign Up topic availability reminder is a very explanatory example of Asynchronous Events.&lt;br /&gt;
&lt;br /&gt;
Below mentioned are the changes made in each of the Mailer implementation and in related files.&lt;br /&gt;
&lt;br /&gt;
===Synchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
The asynchronous emailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
==Other Issues==&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation Steps to check Mailer==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91106</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91106"/>
		<updated>2014-10-30T01:34:43Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Assignment Controller */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
[http://guides.rubyonrails.org/action_mailer_basics.html Action Mailer] supports email functionality within a Rails application, which involves sending and receiving emails from and to an application. The scope of the Action Mailer within Expertiza is limited to sending emails only which we have proposed to extend to 'Receiving' under the heading ‘Future Work’.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
===Problem Definition===&lt;br /&gt;
Design strategy has been one of the major issue for erratic behavior of Mailer within Expertiza. From past few years the Expertiza has been combined with various enhancements and the code has been changed by different teams, the difference in the implementation practices has introduced major design flaws within some components (including Mailer) of the application. Another major issue is the migration issue from Rails 3 to Rails 4 as a result of which many of the unsupported features for Rails 4 have stopped working.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
The aim of this Mailer project is to bring consistency in the design implementation and restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. High-level requirements are listed below:&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
== Mailer in Expertiza==&lt;br /&gt;
&lt;br /&gt;
===Type of Mailers===&lt;br /&gt;
Expertiza has two different Mailer implementations based on type of events: Synchronous events and Asynchronous events. The synchronous events refer to events that should be immediately notified. For example, email should be sent immediately after a review; or after a feedback of the review has been posted; or a user/team is assigned a project, or a social bookmark have been added, etc. Asynchronous Events are a series of timed events which gets triggered at some fixed times, such as weekly quiz reminders, deadline approaching reminders or in fact Sign Up topic availability reminder is a very explanatory example of Asynchronous Events.&lt;br /&gt;
&lt;br /&gt;
Below mentioned are the changes made in each of the Mailer implementation and in related files.&lt;br /&gt;
&lt;br /&gt;
===Synchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
The asynchronous emailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
Each due date for submission, review, meta review, sign up, and drop topic were missing under the Assignment edit page due to the bugs in its views and partials files. The JavaScript implementation was previously done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Other Issues==&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation Steps to check Mailer==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91101</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91101"/>
		<updated>2014-10-30T01:31:29Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Mailer in Expertiza */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
[http://guides.rubyonrails.org/action_mailer_basics.html Action Mailer] supports email functionality within a Rails application, which involves sending and receiving emails from and to an application. The scope of the Action Mailer within Expertiza is limited to sending emails only which we have proposed to extend to 'Receiving' under the heading ‘Future Work’.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
===Problem Definition===&lt;br /&gt;
Design strategy has been one of the major issue for erratic behavior of Mailer within Expertiza. From past few years the Expertiza has been combined with various enhancements and the code has been changed by different teams, the difference in the implementation practices has introduced major design flaws within some components (including Mailer) of the application. Another major issue is the migration issue from Rails 3 to Rails 4 as a result of which many of the unsupported features for Rails 4 have stopped working.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
The aim of this Mailer project is to bring consistency in the design implementation and restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. High-level requirements are listed below:&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
== Mailer in Expertiza==&lt;br /&gt;
&lt;br /&gt;
===Type of Mailers===&lt;br /&gt;
Expertiza has two different Mailer implementations based on type of events: Synchronous events and Asynchronous events. The synchronous events refer to events that should be immediately notified. For example, email should be sent immediately after a review; or after a feedback of the review has been posted; or a user/team is assigned a project, or a social bookmark have been added, etc. Asynchronous Events are a series of timed events which gets triggered at some fixed times, such as weekly quiz reminders, deadline approaching reminders or in fact Sign Up topic availability reminder is a very explanatory example of Asynchronous Events.&lt;br /&gt;
&lt;br /&gt;
Below mentioned are the changes made in each of the Mailer implementation and in related files.&lt;br /&gt;
&lt;br /&gt;
===Synchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
The asynchronous emailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
&lt;br /&gt;
Two types of events will trigger email messages. One is synchronous event; the other is asynchronous event. The synchronous events refer to activities of reviewers and authors. For example, each email should be sent when work has been reviewed; a feedback to the review has been posted; meta review comments, and social bookmark have been added. In addition, when a user is cleared from the waiting list the party should be notified. Our next task is to restore the assignment features in order to examine the asynchronous events. Asynchronous events are a serious of time events. Due to the bugs in views and partials files under the assignment edit page, each due date for submission, review, meta review, sign up, and drop topic is missing. The JavaScript implementation is done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Other Issues==&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation Steps to check Mailer==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91096</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91096"/>
		<updated>2014-10-30T01:30:42Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
[http://guides.rubyonrails.org/action_mailer_basics.html Action Mailer] supports email functionality within a Rails application, which involves sending and receiving emails from and to an application. The scope of the Action Mailer within Expertiza is limited to sending emails only which we have proposed to extend to 'Receiving' under the heading ‘Future Work’.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
===Problem Definition===&lt;br /&gt;
Design strategy has been one of the major issue for erratic behavior of Mailer within Expertiza. From past few years the Expertiza has been combined with various enhancements and the code has been changed by different teams, the difference in the implementation practices has introduced major design flaws within some components (including Mailer) of the application. Another major issue is the migration issue from Rails 3 to Rails 4 as a result of which many of the unsupported features for Rails 4 have stopped working.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
The aim of this Mailer project is to bring consistency in the design implementation and restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. High-level requirements are listed below:&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
== Mailer in Expertiza==&lt;br /&gt;
&lt;br /&gt;
===Type of Mailers===&lt;br /&gt;
Expertiza has two different Mailer implementations based on type of events: Synchronous events and Asynchronous events. The synchronous events refer to events that should be immediately notified. For example, email should be sent immediately after a review; or after a feedback of the review has been posted; or a user/team is assigned a project, or a social bookmark have been added, etc. Asynchronous Events are a series of timed events which gets triggered at some fixed times, such as weekly quiz reminders, deadline approaching reminders or in fact Sign Up topic availability reminder is a very explanatory example of Asynchronous Events.&lt;br /&gt;
&lt;br /&gt;
Below mentioned are the changes made in each of the Mailer implementation and in related files.&lt;br /&gt;
&lt;br /&gt;
===Synchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
The asynchronous emailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
&lt;br /&gt;
Two types of events will trigger email messages. One is synchronous event; the other is asynchronous event. The synchronous events refer to activities of reviewers and authors. For example, each email should be sent when work has been reviewed; a feedback to the review has been posted; meta review comments, and social bookmark have been added. In addition, when a user is cleared from the waiting list the party should be notified. Our next task is to restore the assignment features in order to examine the asynchronous events. Asynchronous events are a serious of time events. Due to the bugs in views and partials files under the assignment edit page, each due date for submission, review, meta review, sign up, and drop topic is missing. The JavaScript implementation is done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Other Issues==&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation Steps to check Mailer==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91064</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91064"/>
		<updated>2014-10-30T01:06:00Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Project Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
[http://guides.rubyonrails.org/action_mailer_basics.html Action Mailer] supports email functionality within a Rails application, which involves sending and receiving emails from and to an application. The scope of the Action Mailer within Expertiza is limited to sending emails only which we have proposed to extend to 'Receiving' under the heading ‘Future Work’.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
===Problem Definition===&lt;br /&gt;
Design strategy has been one of the major issue for erratic behavior of Mailer within Expertiza. From past few years the Expertiza has been combined with various enhancements and the code has been changed by different teams, the difference in the implementation practices has introduced major design flaws within some components (including Mailer) of the application. Another major issue is the migration issue from Rails 3 to Rails 4 as a result of which many of the unsupported features for Rails 4 have stopped working.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
The aim of this Mailer project is to bring consistency in the design implementation and restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. High-level requirements are listed below:&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
== Modification to Existing Code==&lt;br /&gt;
&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models.&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
&lt;br /&gt;
Two types of events will trigger email messages. One is synchronous event; the other is asynchronous event. The synchronous events refer to activities of reviewers and authors. For example, each email should be sent when work has been reviewed; a feedback to the review has been posted; meta review comments, and social bookmark have been added. In addition, when a user is cleared from the waiting list the party should be notified. Our next task is to restore the assignment features in order to examine the asynchronous events. Asynchronous events are a serious of time events. Due to the bugs in views and partials files under the assignment edit page, each due date for submission, review, meta review, sign up, and drop topic is missing. The JavaScript implementation is done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Synchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
The asynchronous emailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
==Installation Steps==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91059</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91059"/>
		<updated>2014-10-30T01:03:37Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
[http://guides.rubyonrails.org/action_mailer_basics.html Action Mailer] supports email functionality within a Rails application, which involves sending and receiving emails from and to an application. The scope of the Action Mailer within Expertiza is limited to sending emails only which we have proposed to extend to 'Receiving' under the heading ‘Future Work’.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
===Problem with existing Mailer===&lt;br /&gt;
Design strategy has been one of the major issue for erratic behavior of Mailer within Expertiza. From past few years the Expertiza has been combined with various enhancements and the code has been changed by different teams, the difference in the implementation practices has introduced major design flaws within some components (including Mailer) of the application.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
The aim of this Mailer project is to bring consistency in the design implementation and restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. High-level requirements are listed below:&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
== Modification to Existing Code==&lt;br /&gt;
&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models.&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
&lt;br /&gt;
Two types of events will trigger email messages. One is synchronous event; the other is asynchronous event. The synchronous events refer to activities of reviewers and authors. For example, each email should be sent when work has been reviewed; a feedback to the review has been posted; meta review comments, and social bookmark have been added. In addition, when a user is cleared from the waiting list the party should be notified. Our next task is to restore the assignment features in order to examine the asynchronous events. Asynchronous events are a serious of time events. Due to the bugs in views and partials files under the assignment edit page, each due date for submission, review, meta review, sign up, and drop topic is missing. The JavaScript implementation is done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Synchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
The asynchronous emailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
==Installation Steps==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91038</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91038"/>
		<updated>2014-10-30T00:31:45Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
[http://guides.rubyonrails.org/action_mailer_basics.html Action Mailer] supports email functionality within a Rails application, which involves sending and receiving emails from and to an application. The scope of the Action Mailer within Expertiza is limited to sending emails only which we have proposed to extend to 'Receiving' under the heading ‘Future Work’.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
Although combined with various enhancements from the past two years, is seriously broken, from data migration to key feature implementation. Part of the reason has been the design strategy and code changes by various teams. The Expertiza Emailer team, consisting of three students, aims to restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
== Modification to Existing Code==&lt;br /&gt;
&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models.&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
&lt;br /&gt;
Two types of events will trigger email messages. One is synchronous event; the other is asynchronous event. The synchronous events refer to activities of reviewers and authors. For example, each email should be sent when work has been reviewed; a feedback to the review has been posted; meta review comments, and social bookmark have been added. In addition, when a user is cleared from the waiting list the party should be notified. Our next task is to restore the assignment features in order to examine the asynchronous events. Asynchronous events are a serious of time events. Due to the bugs in views and partials files under the assignment edit page, each due date for submission, review, meta review, sign up, and drop topic is missing. The JavaScript implementation is done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Synchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
The asynchronous emailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
==Installation Steps==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91032</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91032"/>
		<updated>2014-10-30T00:25:07Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and educational purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
Although combined with various enhancements from the past two years, is seriously broken, from data migration to key feature implementation. Part of the reason has been the design strategy and code changes by various teams. The Expertiza Emailer team, consisting of three students, aims to restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
== Modification to Existing Code==&lt;br /&gt;
&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models.&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
&lt;br /&gt;
Two types of events will trigger email messages. One is synchronous event; the other is asynchronous event. The synchronous events refer to activities of reviewers and authors. For example, each email should be sent when work has been reviewed; a feedback to the review has been posted; meta review comments, and social bookmark have been added. In addition, when a user is cleared from the waiting list the party should be notified. Our next task is to restore the assignment features in order to examine the asynchronous events. Asynchronous events are a serious of time events. Due to the bugs in views and partials files under the assignment edit page, each due date for submission, review, meta review, sign up, and drop topic is missing. The JavaScript implementation is done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Synchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
The asynchronous emailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
==Installation Steps==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91031</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91031"/>
		<updated>2014-10-30T00:23:20Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[http://http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and education purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
Although combined with various enhancements from the past two years, is seriously broken, from data migration to key feature implementation. Part of the reason has been the design strategy and code changes by various teams. The Expertiza Emailer team, consisting of three students, aims to restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
== Modification to Existing Code==&lt;br /&gt;
&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models.&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
&lt;br /&gt;
Two types of events will trigger email messages. One is synchronous event; the other is asynchronous event. The synchronous events refer to activities of reviewers and authors. For example, each email should be sent when work has been reviewed; a feedback to the review has been posted; meta review comments, and social bookmark have been added. In addition, when a user is cleared from the waiting list the party should be notified. Our next task is to restore the assignment features in order to examine the asynchronous events. Asynchronous events are a serious of time events. Due to the bugs in views and partials files under the assignment edit page, each due date for submission, review, meta review, sign up, and drop topic is missing. The JavaScript implementation is done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Synchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
The asynchronous emailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
==Installation Steps==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91026</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91026"/>
		<updated>2014-10-30T00:22:00Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
Expertiza&amp;lt;ref name=&amp;quot;expertiza&amp;gt;''Expertiza'' http://wikis.lib.ncsu.edu/index.php/Expertiza&amp;lt;/ref&amp;gt;, an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual student projects which involves  team creation, project sign up, project submissions, document upload (almost any format), and carry out multiple peer review processes for learning and education purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed and consumed by students of class CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
Although combined with various enhancements from the past two years, is seriously broken, from data migration to key feature implementation. Part of the reason has been the design strategy and code changes by various teams. The Expertiza Emailer team, consisting of three students, aims to restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
== Modification to Existing Code==&lt;br /&gt;
&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models.&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
&lt;br /&gt;
Two types of events will trigger email messages. One is synchronous event; the other is asynchronous event. The synchronous events refer to activities of reviewers and authors. For example, each email should be sent when work has been reviewed; a feedback to the review has been posted; meta review comments, and social bookmark have been added. In addition, when a user is cleared from the waiting list the party should be notified. Our next task is to restore the assignment features in order to examine the asynchronous events. Asynchronous events are a serious of time events. Due to the bugs in views and partials files under the assignment edit page, each due date for submission, review, meta review, sign up, and drop topic is missing. The JavaScript implementation is done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Synchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
The asynchronous emailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
==Installation Steps==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91019</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=91019"/>
		<updated>2014-10-30T00:16:48Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
Expertiza&amp;lt;ref name=&amp;quot;expertiza&amp;gt;''Expertiza'' http://wikis.lib.ncsu.edu/index.php/Expertiza&amp;lt;/ref&amp;gt;, an [http://en.wikipedia.org/wiki/Open-source_software Open Source] [http://rubyonrails.org/ Rails] application designed to support team/individual projects, submissions of almost any document type, and carry out multiple peer review processes for learning and education purpose. The rationale behind Expertiza is that the students should not only be consumers but also creator of educational resources. Based on this philosophy, the tool is extensively managed, and consumed by students of CSC517 Object Oriented Programming Languages and Systems course at NC State University as their main project management tool. This Open Source application can be cloned from [https://github.com/expertiza/expertiza/ Github], the latest active branch is &amp;quot;Rails 4&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
Although combined with various enhancements from the past two years, is seriously broken, from data migration to key feature implementation. Part of the reason has been the design strategy and code changes by various teams. The Expertiza Emailer team, consisting of three students, aims to restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
== Modification to Existing Code==&lt;br /&gt;
&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models.&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
&lt;br /&gt;
Two types of events will trigger email messages. One is synchronous event; the other is asynchronous event. The synchronous events refer to activities of reviewers and authors. For example, each email should be sent when work has been reviewed; a feedback to the review has been posted; meta review comments, and social bookmark have been added. In addition, when a user is cleared from the waiting list the party should be notified. Our next task is to restore the assignment features in order to examine the asynchronous events. Asynchronous events are a serious of time events. Due to the bugs in views and partials files under the assignment edit page, each due date for submission, review, meta review, sign up, and drop topic is missing. The JavaScript implementation is done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Synchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
The asynchronous emailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
==Installation Steps==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=90993</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=90993"/>
		<updated>2014-10-29T23:48:52Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1451 - Create Mailers for All Email Messages''' =&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Expertiza&amp;lt;ref name=&amp;quot;expertiza&amp;gt;''Expertiza'' http://wikis.lib.ncsu.edu/index.php/Expertiza&amp;lt;/ref&amp;gt;, an open source web application designed to carry out multiple peer review processes for learning and education purpose, has been used by CSC517 Object Oriented Programming Languages and Systems course at NC State University as the main project management tool. The latest &amp;quot;Rails 4&amp;quot; branch of Expertiza, although combined with various enhancements from the past two years, is seriously broken, from data migration to key feature implementation. Part of the reason has been the design strategy and code changes by various teams. The Expertiza Emailer team, consisting of three students, aims to restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
== Modification to Existing Code==&lt;br /&gt;
&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models.&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
&lt;br /&gt;
Two types of events will trigger email messages. One is synchronous event; the other is asynchronous event. The synchronous events refer to activities of reviewers and authors. For example, each email should be sent when work has been reviewed; a feedback to the review has been posted; meta review comments, and social bookmark have been added. In addition, when a user is cleared from the waiting list the party should be notified. Our next task is to restore the assignment features in order to examine the asynchronous events. Asynchronous events are a serious of time events. Due to the bugs in views and partials files under the assignment edit page, each due date for submission, review, meta review, sign up, and drop topic is missing. The JavaScript implementation is done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Synchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
The asynchronous emailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
==Installation Steps==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=90991</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1451 las</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1451_las&amp;diff=90991"/>
		<updated>2014-10-29T23:47:29Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1451 - Create Mailers for All Email Messages=&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:Logo.jpg|center|Expertiza + ActionMailer&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/images/d/d4/Logo.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://guides.rubyonrails.org/action_mailer_basics.html ActionMailer] + [http://http://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Expertiza&amp;lt;ref name=&amp;quot;expertiza&amp;gt;''Expertiza'' http://wikis.lib.ncsu.edu/index.php/Expertiza&amp;lt;/ref&amp;gt;, an open source web application designed to carry out multiple peer review processes for learning and education purpose, has been used by CSC517 Object Oriented Programming Languages and Systems course at NC State University as the main project management tool. The latest &amp;quot;Rails 4&amp;quot; branch of Expertiza, although combined with various enhancements from the past two years, is seriously broken, from data migration to key feature implementation. Part of the reason has been the design strategy and code changes by various teams. The Expertiza Emailer team, consisting of three students, aims to restore the e-mailer and e-mail messages capability from Projects E701 and E729, and bring back the new features created by Project E916. Significant amount of time has been spent on correcting bugs and errors in the program before the email features can be restored, and therefore this wiki also documents the changes our team has made and provides a guideline for future development and enhancement.&lt;br /&gt;
&lt;br /&gt;
==Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. Restore features and functions in Expertiza that trigger email messages&lt;br /&gt;
&lt;br /&gt;
2. Create mailers for all email messages for both asynchronous events and synchronous events&lt;br /&gt;
&lt;br /&gt;
3. All emails should be sent via ActionMailer&lt;br /&gt;
&lt;br /&gt;
4. Emails should have different class&lt;br /&gt;
&lt;br /&gt;
== Modification to Existing Code==&lt;br /&gt;
&lt;br /&gt;
===Data migration issue===&lt;br /&gt;
&lt;br /&gt;
The database migration issue occurs when carrying out &amp;quot;rake db:migrate&amp;quot; command. We found the mirrored image from the existing database still has incorrect table fields. The problem may not appear until later during feature testing. Therefore, our team decided to fix the data migration issues from ground up. In total, more than 36 files have been fixed. Most of them are database migration files. To eliminate future table creation issues with mysql2 gem, we have also changed the integer byte length of MySQL tables from 10 to 8 and have revised the SQL query methods inside the migration files to improve efficiency. The methods missing from the models directory related to site_controller have been restored for controller_action, menu_item, permission, role, and site_controller models.&lt;br /&gt;
&lt;br /&gt;
===Assignment Controller===&lt;br /&gt;
&lt;br /&gt;
Two types of events will trigger email messages. One is synchronous event; the other is asynchronous event. The synchronous events refer to activities of reviewers and authors. For example, each email should be sent when work has been reviewed; a feedback to the review has been posted; meta review comments, and social bookmark have been added. In addition, when a user is cleared from the waiting list the party should be notified. Our next task is to restore the assignment features in order to examine the asynchronous events. Asynchronous events are a serious of time events. Due to the bugs in views and partials files under the assignment edit page, each due date for submission, review, meta review, sign up, and drop topic is missing. The JavaScript implementation is done via JQuery gem. After the JavaScript has been fixed, now the correct due dates are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
The following changes have been made:&lt;br /&gt;
&lt;br /&gt;
1. All *.rhtml files in app/views/bookmarks have been renamed to *.html.erb for compatibly reason.&lt;br /&gt;
&lt;br /&gt;
2. The following lines have been added to Gemfile&lt;br /&gt;
&lt;br /&gt;
    gem 'jquery-datetimepicker-rails'&lt;br /&gt;
    gem 'graphr'&lt;br /&gt;
    gem 'daemons'&lt;br /&gt;
&lt;br /&gt;
3. The following parsing errors in app/controllers/assignment_controller.rb have been corrected.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date(:db).to_s&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    duatedates[i].due_date.to_s(:db)&lt;br /&gt;
&lt;br /&gt;
4. The following code in ap/views/assignments/edit/_rubrics.html.erb has been changed.&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.review_questionnaire&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;.assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
    &amp;lt;%= assignment_questionnaire(@assignment, 'ReviewQuestionnaire').to_json.html_safe %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Synchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
All of synchronous events are triggered by controllers and the call is made to app/mailers/mailer.rb (formally as model in /app/models/) via the sync_message() method call. Here mailer.rb extends ActionMailer class. Because part of the email implementation was done on Rails 3 platform, to make it compatible for Rails 4, revision has been made. The required email template has been added for both generic_message and sync_message method calls. Here is an example of synchronous event email that simulates an event when the work you reviewed before has been revised.&lt;br /&gt;
&lt;br /&gt;
1. app/models/mailer.rb has been moved to app/mailers/mailer.rb&lt;br /&gt;
&lt;br /&gt;
2. Two view templates have been added to app/views/mailer directory. They are sync_message.html.erb and sync_message.text.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
    &amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
      &amp;lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;%= render :partial =&amp;gt; 'mailer/partials/'+@partial_name+'_html' %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    This message has been generated by &amp;lt;A HREF=&amp;quot;http://expertiza.ncsu.edu&amp;quot;&amp;gt;Expertiza&amp;lt;/A&amp;gt;&amp;lt;BR/&amp;gt;&lt;br /&gt;
    http://expertiza.ncsu.edu&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
    &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Correct DOCTYPE and html codes have been added to app/views/mailer/generic_message.html.erb&lt;br /&gt;
&lt;br /&gt;
4. The following line in the sync_message(defn) method has been comment out from app/mailers/mailer.rb in order to encode email correctly.&lt;br /&gt;
&lt;br /&gt;
    content_type: &amp;quot;text/html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
5. The following method calls in the following files have been changed.&lt;br /&gt;
&lt;br /&gt;
a) app/controllers/grades_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) app/models/courses_users.rb&amp;lt;br&amp;gt;&lt;br /&gt;
c) app/models/participant.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Original:&lt;br /&gt;
&lt;br /&gt;
    Mailer.deliver_message(&lt;br /&gt;
&lt;br /&gt;
Changed:&lt;br /&gt;
&lt;br /&gt;
    Mailer.sync_message(&lt;br /&gt;
&lt;br /&gt;
===Asynchronous Emailer===&lt;br /&gt;
&lt;br /&gt;
The asynchronous emailer is controlled by Delayed::Job class and a daemon gem must be activated to carry out the task. All events are called to /app/emailers/delayed_mailer.rb via one of the following methods: email_reminder(), mail_assignment_participants(), mail_reviewers(), mail_metareivewers(), getTeamMembersMail(), and mail_signed_up_users(). The DelayedMailer class acts as a wrapper class to the Mailer class in the /app/mailers/mailer.rb via the delayed_message() method call. These events are added to the queue by Delayed::Job.enqueue() command. Each event as record is stored in the delayed_job table, which can be browsed on RubyMine. Because all of the asynchronous events are controlled by the assignment controller, events are triggered by the add_to_delayed_queue() method. Each time when an assignment is updated or saved, event queues are refreshed. We found this is not very efficient but it has worked as expected.&lt;br /&gt;
&lt;br /&gt;
===RSpec test cases===&lt;br /&gt;
&lt;br /&gt;
To test the emailer features, we have restored RSpec test cases for both delayed_mailer.rb (asynchronous maier) and mailer.rb (synchronous mailer). Because the existing RSpec files were developed in RSpec 2.x, upgrade is required. Ideally, the files in /test/fixtures should be used to populate the test data for RSpec, and therefore we did not restore all the files in /spec/fixtures/ directory. Currently, the fixture files are not completed and loading them into the test database may cause failure for the test, so we recommend to comment out the following line in the /spec/rails_helper.rb&lt;br /&gt;
&lt;br /&gt;
    #config.global_fixtures = :all&lt;br /&gt;
&lt;br /&gt;
Future developers must take extreme care to make sure all fixture files work before enable this option.&lt;br /&gt;
&lt;br /&gt;
1. Two files have been added spec/ directory:&lt;br /&gt;
&lt;br /&gt;
a) spec/integration/delayed_mailer_spec.rb&amp;lt;br&amp;gt;&lt;br /&gt;
b) spec/models/mailer_spec.rb&lt;br /&gt;
&lt;br /&gt;
The following code has been added to each test case:&lt;br /&gt;
&lt;br /&gt;
    Delayed::Job.delete_all&lt;br /&gt;
&lt;br /&gt;
2. The following code has been added to spec/rails_helper.rb in order for the RSpec to pass the test.&lt;br /&gt;
&lt;br /&gt;
    ENV[&amp;quot;RAILS_ENV&amp;quot;] ||= 'test'&lt;br /&gt;
    require File.expand_path(&amp;quot;../../config/environment&amp;quot;, __FILE__)&lt;br /&gt;
    require 'rspec/rails'&lt;br /&gt;
    require 'rspec/autorun'&lt;br /&gt;
    require 'capybara/rspec'&lt;br /&gt;
    require 'capybara/rails'&lt;br /&gt;
&lt;br /&gt;
==Installation Steps==&lt;br /&gt;
&lt;br /&gt;
Because asynchronous events require a daemon running in the background and the new Delayed Job for Rails 4 has additional fields, the following steps are recommended.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Install Expertiza and execute 'bundle install'&lt;br /&gt;
&lt;br /&gt;
2. Create database and perform data migration using 'rake db:migrate'&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Execute 'rails generate delayed_job:active_record' at the prompt. This will create a delalyed_job file in /bin directory. &lt;br /&gt;
&lt;br /&gt;
4. Execute 'rails generate delayed:upgrade' if delayed_job has been created before.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Start the delayed_job server by executing&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     RAILS_ENV=production bin/delayed_job start&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues and Future Work==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The due date for signup activity may not display correctly. To refresh, users must click the &amp;quot;review round&amp;quot; button or the &amp;quot;save&amp;quot; button again.&lt;br /&gt;
&lt;br /&gt;
2. Each time when an assignment is saved all delayed_job tasks will be deleted and refreshed even if the dates have not been changed. This may not be very efficiency and may cause problems in the future. Checking mechanism should be built in to verify if any date has been changed.&lt;br /&gt;
&lt;br /&gt;
3. DateTimePicker field could be accidently changed by mouse click. &lt;br /&gt;
&lt;br /&gt;
4. Prioritization in the Delayed Job function in case of multiple email load&lt;br /&gt;
&lt;br /&gt;
5. Extending functionality to include Weekly/Monthly digest that can consist of users WebAssign summary.&lt;br /&gt;
&lt;br /&gt;
6. In-built messaging (Inbox, Sent, Draft etc.) functionality in addition to email for easy tracking  of outgoing and incoming messages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Logo.jpg&amp;diff=90986</id>
		<title>File:Logo.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Logo.jpg&amp;diff=90986"/>
		<updated>2014-10-29T23:42:37Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: Expertiza + ActionMailer logo
http://expertiza.ncsu.edu/&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Expertiza + ActionMailer logo&lt;br /&gt;
http://expertiza.ncsu.edu/&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89600</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89600"/>
		<updated>2014-10-15T04:37:49Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Prerequisiteshttp://angular-rails.com/ */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&amp;lt;ref&amp;gt;http://code.tutsplus.com/tutorials/5-awesome-angularjs-features--net-25651&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration.&amp;lt;ref&amp;gt;https://www.codeschool.com/courses/shaping-up-with-angular-js&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&amp;lt;ref&amp;gt;http://joelhooks.com/blog/2013/09/15/why-i-built-an-angularjs-training-site-on-rails&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Getting Started&amp;lt;ref&amp;gt;http://sebastien.saunier.me/blog/2014/02/04/angular--rails-with-no-fuss.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&amp;lt;ref&amp;gt;http://angular-rails.com/&amp;lt;/ref&amp;gt;&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: Restauranteur &amp;lt;ref&amp;gt;http://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finally Seed the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/seeds.rb&lt;br /&gt;
&lt;br /&gt;
Restaurant.create([&lt;br /&gt;
  { name: &amp;quot;The French Laundry&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Chez Panisse&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Bouchon&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Noma&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Taco Bell&amp;quot; },&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own '''Controller'''. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller '''HomeCtrl'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 4: Create Templates and Modify Controller ===&lt;br /&gt;
&lt;br /&gt;
Make changes in the layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make template for restaurants (this can be created anywhere), we are making it under public directory and create and index page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- public/templates/restaurants/index.html --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;/#&amp;quot;&amp;gt;index&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;ul ng-repeat=&amp;quot;restaurant in restaurants&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&amp;lt;a ng-click=&amp;quot;viewRestaurant(restaurant.id)&amp;quot;&amp;gt;{{ restaurant.name }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
create Restaurant Index Controller&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'RestaurantIndexCtrl', ['$scope', '$location', '$http', ($scope, $location, $http) -&amp;gt;&lt;br /&gt;
  $scope.restaurants = []&lt;br /&gt;
  $http.get('./restaurants.json').success((data) -&amp;gt;&lt;br /&gt;
    $scope.restaurants = data&lt;br /&gt;
  )&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 5: Adjust Routing in main.js===&lt;br /&gt;
&lt;br /&gt;
Now modify routing so that new Restaurant Index page is called.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/main.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur = angular.module('restauranteur', [])&lt;br /&gt;
&lt;br /&gt;
@restauranteur.config(['$routeProvider', ($routeProvider) -&amp;gt;&lt;br /&gt;
  $routeProvider.&lt;br /&gt;
    when('/restaurants', {&lt;br /&gt;
      templateUrl: '../templates/restaurants/index.html',&lt;br /&gt;
      controller: 'RestaurantIndexCtrl'&lt;br /&gt;
    })&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's done! Now go to URI /#/restaurants to see list of Restaurants we added.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
For testing we are going to use Rspec, Karma, and Jasmine framework. We start by first installing Karma server:&lt;br /&gt;
&lt;br /&gt;
====For Ubuntu====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo npm install -g karma&lt;br /&gt;
sudo npm install -g karma-ng-scenario&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====For Windows====&lt;br /&gt;
Install via Git bash&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install -g karma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step by step Testing Procedure===&lt;br /&gt;
Create Test Folder&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir spec/javascripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write Tests&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# spec/javascripts/controllers_spec.js.coffee&lt;br /&gt;
&lt;br /&gt;
describe &amp;quot;Restauranteur controllers&amp;quot;, -&amp;gt;&lt;br /&gt;
  beforeEach module(&amp;quot;restauranteur&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;RestaurantIndexCtrl&amp;quot;, -&amp;gt;&lt;br /&gt;
    it &amp;quot;should set restaurants to an empty array&amp;quot;, inject(($controller) -&amp;gt;&lt;br /&gt;
      scope = {}&lt;br /&gt;
      ctrl = $controller(&amp;quot;RestaurantIndexCtrl&amp;quot;,&lt;br /&gt;
        $scope: scope&lt;br /&gt;
      )&lt;br /&gt;
      expect(scope.restaurants.length).toBe 0&lt;br /&gt;
    )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Configurations&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&lt;br /&gt;
module.exports = function(config) {&lt;br /&gt;
  config.set({&lt;br /&gt;
    basePath: '../..',&lt;br /&gt;
&lt;br /&gt;
    frameworks: ['jasmine'],&lt;br /&gt;
&lt;br /&gt;
    autoWatch: true,&lt;br /&gt;
&lt;br /&gt;
    preprocessors: {&lt;br /&gt;
      '**/*.coffee': 'coffee'&lt;br /&gt;
    }, &lt;br /&gt;
&lt;br /&gt;
    files: [&lt;br /&gt;
      'app/assets/javascripts/angular.js',&lt;br /&gt;
      'app/assets/javascripts/angular-mocks.js',&lt;br /&gt;
      'app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee',&lt;br /&gt;
      'app/assets/javascripts/angular/*',&lt;br /&gt;
      'spec/javascripts/*_spec.js.coffee'&lt;br /&gt;
    ]  &lt;br /&gt;
  });&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Karma Server&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
karma start spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to go to http://localhost:9876/ and test will run and be successful.&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89599</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89599"/>
		<updated>2014-10-15T04:37:12Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Getting Startedhttp://sebastien.saunier.me/blog/2014/02/04/angular--rails-with-no-fuss.html */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&amp;lt;ref&amp;gt;http://code.tutsplus.com/tutorials/5-awesome-angularjs-features--net-25651&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration.&amp;lt;ref&amp;gt;https://www.codeschool.com/courses/shaping-up-with-angular-js&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&amp;lt;ref&amp;gt;http://joelhooks.com/blog/2013/09/15/why-i-built-an-angularjs-training-site-on-rails&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Getting Started&amp;lt;ref&amp;gt;http://sebastien.saunier.me/blog/2014/02/04/angular--rails-with-no-fuss.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
===Prerequisites&amp;lt;ref&amp;gt;http://angular-rails.com/&amp;lt;/ref&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: Restauranteur &amp;lt;ref&amp;gt;http://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finally Seed the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/seeds.rb&lt;br /&gt;
&lt;br /&gt;
Restaurant.create([&lt;br /&gt;
  { name: &amp;quot;The French Laundry&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Chez Panisse&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Bouchon&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Noma&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Taco Bell&amp;quot; },&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own '''Controller'''. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller '''HomeCtrl'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 4: Create Templates and Modify Controller ===&lt;br /&gt;
&lt;br /&gt;
Make changes in the layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make template for restaurants (this can be created anywhere), we are making it under public directory and create and index page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- public/templates/restaurants/index.html --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;/#&amp;quot;&amp;gt;index&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;ul ng-repeat=&amp;quot;restaurant in restaurants&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&amp;lt;a ng-click=&amp;quot;viewRestaurant(restaurant.id)&amp;quot;&amp;gt;{{ restaurant.name }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
create Restaurant Index Controller&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'RestaurantIndexCtrl', ['$scope', '$location', '$http', ($scope, $location, $http) -&amp;gt;&lt;br /&gt;
  $scope.restaurants = []&lt;br /&gt;
  $http.get('./restaurants.json').success((data) -&amp;gt;&lt;br /&gt;
    $scope.restaurants = data&lt;br /&gt;
  )&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 5: Adjust Routing in main.js===&lt;br /&gt;
&lt;br /&gt;
Now modify routing so that new Restaurant Index page is called.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/main.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur = angular.module('restauranteur', [])&lt;br /&gt;
&lt;br /&gt;
@restauranteur.config(['$routeProvider', ($routeProvider) -&amp;gt;&lt;br /&gt;
  $routeProvider.&lt;br /&gt;
    when('/restaurants', {&lt;br /&gt;
      templateUrl: '../templates/restaurants/index.html',&lt;br /&gt;
      controller: 'RestaurantIndexCtrl'&lt;br /&gt;
    })&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's done! Now go to URI /#/restaurants to see list of Restaurants we added.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
For testing we are going to use Rspec, Karma, and Jasmine framework. We start by first installing Karma server:&lt;br /&gt;
&lt;br /&gt;
====For Ubuntu====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo npm install -g karma&lt;br /&gt;
sudo npm install -g karma-ng-scenario&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====For Windows====&lt;br /&gt;
Install via Git bash&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install -g karma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step by step Testing Procedure===&lt;br /&gt;
Create Test Folder&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir spec/javascripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write Tests&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# spec/javascripts/controllers_spec.js.coffee&lt;br /&gt;
&lt;br /&gt;
describe &amp;quot;Restauranteur controllers&amp;quot;, -&amp;gt;&lt;br /&gt;
  beforeEach module(&amp;quot;restauranteur&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;RestaurantIndexCtrl&amp;quot;, -&amp;gt;&lt;br /&gt;
    it &amp;quot;should set restaurants to an empty array&amp;quot;, inject(($controller) -&amp;gt;&lt;br /&gt;
      scope = {}&lt;br /&gt;
      ctrl = $controller(&amp;quot;RestaurantIndexCtrl&amp;quot;,&lt;br /&gt;
        $scope: scope&lt;br /&gt;
      )&lt;br /&gt;
      expect(scope.restaurants.length).toBe 0&lt;br /&gt;
    )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Configurations&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&lt;br /&gt;
module.exports = function(config) {&lt;br /&gt;
  config.set({&lt;br /&gt;
    basePath: '../..',&lt;br /&gt;
&lt;br /&gt;
    frameworks: ['jasmine'],&lt;br /&gt;
&lt;br /&gt;
    autoWatch: true,&lt;br /&gt;
&lt;br /&gt;
    preprocessors: {&lt;br /&gt;
      '**/*.coffee': 'coffee'&lt;br /&gt;
    }, &lt;br /&gt;
&lt;br /&gt;
    files: [&lt;br /&gt;
      'app/assets/javascripts/angular.js',&lt;br /&gt;
      'app/assets/javascripts/angular-mocks.js',&lt;br /&gt;
      'app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee',&lt;br /&gt;
      'app/assets/javascripts/angular/*',&lt;br /&gt;
      'spec/javascripts/*_spec.js.coffee'&lt;br /&gt;
    ]  &lt;br /&gt;
  });&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Karma Server&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
karma start spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to go to http://localhost:9876/ and test will run and be successful.&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89598</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89598"/>
		<updated>2014-10-15T04:35:20Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Getting Startedhttp://sebastien.saunier.me/blog/2014/02/04/angular--rails-with-no-fuss.html */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&amp;lt;ref&amp;gt;http://code.tutsplus.com/tutorials/5-awesome-angularjs-features--net-25651&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration.&amp;lt;ref&amp;gt;https://www.codeschool.com/courses/shaping-up-with-angular-js&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&amp;lt;ref&amp;gt;http://joelhooks.com/blog/2013/09/15/why-i-built-an-angularjs-training-site-on-rails&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Getting Started&amp;lt;ref&amp;gt;http://sebastien.saunier.me/blog/2014/02/04/angular--rails-with-no-fuss.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
===Prerequisites===&amp;lt;ref&amp;gt;http://angular-rails.com/&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: Restauranteur &amp;lt;ref&amp;gt;http://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finally Seed the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/seeds.rb&lt;br /&gt;
&lt;br /&gt;
Restaurant.create([&lt;br /&gt;
  { name: &amp;quot;The French Laundry&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Chez Panisse&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Bouchon&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Noma&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Taco Bell&amp;quot; },&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own '''Controller'''. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller '''HomeCtrl'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 4: Create Templates and Modify Controller ===&lt;br /&gt;
&lt;br /&gt;
Make changes in the layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make template for restaurants (this can be created anywhere), we are making it under public directory and create and index page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- public/templates/restaurants/index.html --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;/#&amp;quot;&amp;gt;index&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;ul ng-repeat=&amp;quot;restaurant in restaurants&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&amp;lt;a ng-click=&amp;quot;viewRestaurant(restaurant.id)&amp;quot;&amp;gt;{{ restaurant.name }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
create Restaurant Index Controller&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'RestaurantIndexCtrl', ['$scope', '$location', '$http', ($scope, $location, $http) -&amp;gt;&lt;br /&gt;
  $scope.restaurants = []&lt;br /&gt;
  $http.get('./restaurants.json').success((data) -&amp;gt;&lt;br /&gt;
    $scope.restaurants = data&lt;br /&gt;
  )&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 5: Adjust Routing in main.js===&lt;br /&gt;
&lt;br /&gt;
Now modify routing so that new Restaurant Index page is called.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/main.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur = angular.module('restauranteur', [])&lt;br /&gt;
&lt;br /&gt;
@restauranteur.config(['$routeProvider', ($routeProvider) -&amp;gt;&lt;br /&gt;
  $routeProvider.&lt;br /&gt;
    when('/restaurants', {&lt;br /&gt;
      templateUrl: '../templates/restaurants/index.html',&lt;br /&gt;
      controller: 'RestaurantIndexCtrl'&lt;br /&gt;
    })&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's done! Now go to URI /#/restaurants to see list of Restaurants we added.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
For testing we are going to use Rspec, Karma, and Jasmine framework. We start by first installing Karma server:&lt;br /&gt;
&lt;br /&gt;
====For Ubuntu====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo npm install -g karma&lt;br /&gt;
sudo npm install -g karma-ng-scenario&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====For Windows====&lt;br /&gt;
Install via Git bash&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install -g karma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step by step Testing Procedure===&lt;br /&gt;
Create Test Folder&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir spec/javascripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write Tests&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# spec/javascripts/controllers_spec.js.coffee&lt;br /&gt;
&lt;br /&gt;
describe &amp;quot;Restauranteur controllers&amp;quot;, -&amp;gt;&lt;br /&gt;
  beforeEach module(&amp;quot;restauranteur&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;RestaurantIndexCtrl&amp;quot;, -&amp;gt;&lt;br /&gt;
    it &amp;quot;should set restaurants to an empty array&amp;quot;, inject(($controller) -&amp;gt;&lt;br /&gt;
      scope = {}&lt;br /&gt;
      ctrl = $controller(&amp;quot;RestaurantIndexCtrl&amp;quot;,&lt;br /&gt;
        $scope: scope&lt;br /&gt;
      )&lt;br /&gt;
      expect(scope.restaurants.length).toBe 0&lt;br /&gt;
    )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Configurations&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&lt;br /&gt;
module.exports = function(config) {&lt;br /&gt;
  config.set({&lt;br /&gt;
    basePath: '../..',&lt;br /&gt;
&lt;br /&gt;
    frameworks: ['jasmine'],&lt;br /&gt;
&lt;br /&gt;
    autoWatch: true,&lt;br /&gt;
&lt;br /&gt;
    preprocessors: {&lt;br /&gt;
      '**/*.coffee': 'coffee'&lt;br /&gt;
    }, &lt;br /&gt;
&lt;br /&gt;
    files: [&lt;br /&gt;
      'app/assets/javascripts/angular.js',&lt;br /&gt;
      'app/assets/javascripts/angular-mocks.js',&lt;br /&gt;
      'app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee',&lt;br /&gt;
      'app/assets/javascripts/angular/*',&lt;br /&gt;
      'spec/javascripts/*_spec.js.coffee'&lt;br /&gt;
    ]  &lt;br /&gt;
  });&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Karma Server&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
karma start spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to go to http://localhost:9876/ and test will run and be successful.&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89597</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89597"/>
		<updated>2014-10-15T04:32:57Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Why AngularJS + Rails? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&amp;lt;ref&amp;gt;http://code.tutsplus.com/tutorials/5-awesome-angularjs-features--net-25651&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration.&amp;lt;ref&amp;gt;https://www.codeschool.com/courses/shaping-up-with-angular-js&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&amp;lt;ref&amp;gt;http://joelhooks.com/blog/2013/09/15/why-i-built-an-angularjs-training-site-on-rails&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Getting Started&amp;lt;ref&amp;gt;http://sebastien.saunier.me/blog/2014/02/04/angular--rails-with-no-fuss.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: Restauranteur &amp;lt;ref&amp;gt;http://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finally Seed the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/seeds.rb&lt;br /&gt;
&lt;br /&gt;
Restaurant.create([&lt;br /&gt;
  { name: &amp;quot;The French Laundry&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Chez Panisse&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Bouchon&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Noma&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Taco Bell&amp;quot; },&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own '''Controller'''. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller '''HomeCtrl'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 4: Create Templates and Modify Controller ===&lt;br /&gt;
&lt;br /&gt;
Make changes in the layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make template for restaurants (this can be created anywhere), we are making it under public directory and create and index page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- public/templates/restaurants/index.html --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;/#&amp;quot;&amp;gt;index&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;ul ng-repeat=&amp;quot;restaurant in restaurants&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&amp;lt;a ng-click=&amp;quot;viewRestaurant(restaurant.id)&amp;quot;&amp;gt;{{ restaurant.name }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
create Restaurant Index Controller&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'RestaurantIndexCtrl', ['$scope', '$location', '$http', ($scope, $location, $http) -&amp;gt;&lt;br /&gt;
  $scope.restaurants = []&lt;br /&gt;
  $http.get('./restaurants.json').success((data) -&amp;gt;&lt;br /&gt;
    $scope.restaurants = data&lt;br /&gt;
  )&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 5: Adjust Routing in main.js===&lt;br /&gt;
&lt;br /&gt;
Now modify routing so that new Restaurant Index page is called.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/main.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur = angular.module('restauranteur', [])&lt;br /&gt;
&lt;br /&gt;
@restauranteur.config(['$routeProvider', ($routeProvider) -&amp;gt;&lt;br /&gt;
  $routeProvider.&lt;br /&gt;
    when('/restaurants', {&lt;br /&gt;
      templateUrl: '../templates/restaurants/index.html',&lt;br /&gt;
      controller: 'RestaurantIndexCtrl'&lt;br /&gt;
    })&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's done! Now go to URI /#/restaurants to see list of Restaurants we added.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
For testing we are going to use Rspec, Karma, and Jasmine framework. We start by first installing Karma server:&lt;br /&gt;
&lt;br /&gt;
====For Ubuntu====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo npm install -g karma&lt;br /&gt;
sudo npm install -g karma-ng-scenario&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====For Windows====&lt;br /&gt;
Install via Git bash&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install -g karma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step by step Testing Procedure===&lt;br /&gt;
Create Test Folder&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir spec/javascripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write Tests&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# spec/javascripts/controllers_spec.js.coffee&lt;br /&gt;
&lt;br /&gt;
describe &amp;quot;Restauranteur controllers&amp;quot;, -&amp;gt;&lt;br /&gt;
  beforeEach module(&amp;quot;restauranteur&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;RestaurantIndexCtrl&amp;quot;, -&amp;gt;&lt;br /&gt;
    it &amp;quot;should set restaurants to an empty array&amp;quot;, inject(($controller) -&amp;gt;&lt;br /&gt;
      scope = {}&lt;br /&gt;
      ctrl = $controller(&amp;quot;RestaurantIndexCtrl&amp;quot;,&lt;br /&gt;
        $scope: scope&lt;br /&gt;
      )&lt;br /&gt;
      expect(scope.restaurants.length).toBe 0&lt;br /&gt;
    )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Configurations&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&lt;br /&gt;
module.exports = function(config) {&lt;br /&gt;
  config.set({&lt;br /&gt;
    basePath: '../..',&lt;br /&gt;
&lt;br /&gt;
    frameworks: ['jasmine'],&lt;br /&gt;
&lt;br /&gt;
    autoWatch: true,&lt;br /&gt;
&lt;br /&gt;
    preprocessors: {&lt;br /&gt;
      '**/*.coffee': 'coffee'&lt;br /&gt;
    }, &lt;br /&gt;
&lt;br /&gt;
    files: [&lt;br /&gt;
      'app/assets/javascripts/angular.js',&lt;br /&gt;
      'app/assets/javascripts/angular-mocks.js',&lt;br /&gt;
      'app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee',&lt;br /&gt;
      'app/assets/javascripts/angular/*',&lt;br /&gt;
      'spec/javascripts/*_spec.js.coffee'&lt;br /&gt;
    ]  &lt;br /&gt;
  });&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Karma Server&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
karma start spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to go to http://localhost:9876/ and test will run and be successful.&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89596</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89596"/>
		<updated>2014-10-15T04:31:55Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&amp;lt;ref&amp;gt;http://code.tutsplus.com/tutorials/5-awesome-angularjs-features--net-25651&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration.&amp;lt;ref&amp;gt;https://www.codeschool.com/courses/shaping-up-with-angular-js&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started&amp;lt;ref&amp;gt;http://sebastien.saunier.me/blog/2014/02/04/angular--rails-with-no-fuss.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: Restauranteur &amp;lt;ref&amp;gt;http://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finally Seed the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/seeds.rb&lt;br /&gt;
&lt;br /&gt;
Restaurant.create([&lt;br /&gt;
  { name: &amp;quot;The French Laundry&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Chez Panisse&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Bouchon&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Noma&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Taco Bell&amp;quot; },&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own '''Controller'''. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller '''HomeCtrl'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 4: Create Templates and Modify Controller ===&lt;br /&gt;
&lt;br /&gt;
Make changes in the layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make template for restaurants (this can be created anywhere), we are making it under public directory and create and index page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- public/templates/restaurants/index.html --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;/#&amp;quot;&amp;gt;index&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;ul ng-repeat=&amp;quot;restaurant in restaurants&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&amp;lt;a ng-click=&amp;quot;viewRestaurant(restaurant.id)&amp;quot;&amp;gt;{{ restaurant.name }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
create Restaurant Index Controller&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'RestaurantIndexCtrl', ['$scope', '$location', '$http', ($scope, $location, $http) -&amp;gt;&lt;br /&gt;
  $scope.restaurants = []&lt;br /&gt;
  $http.get('./restaurants.json').success((data) -&amp;gt;&lt;br /&gt;
    $scope.restaurants = data&lt;br /&gt;
  )&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 5: Adjust Routing in main.js===&lt;br /&gt;
&lt;br /&gt;
Now modify routing so that new Restaurant Index page is called.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/main.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur = angular.module('restauranteur', [])&lt;br /&gt;
&lt;br /&gt;
@restauranteur.config(['$routeProvider', ($routeProvider) -&amp;gt;&lt;br /&gt;
  $routeProvider.&lt;br /&gt;
    when('/restaurants', {&lt;br /&gt;
      templateUrl: '../templates/restaurants/index.html',&lt;br /&gt;
      controller: 'RestaurantIndexCtrl'&lt;br /&gt;
    })&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's done! Now go to URI /#/restaurants to see list of Restaurants we added.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
For testing we are going to use Rspec, Karma, and Jasmine framework. We start by first installing Karma server:&lt;br /&gt;
&lt;br /&gt;
====For Ubuntu====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo npm install -g karma&lt;br /&gt;
sudo npm install -g karma-ng-scenario&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====For Windows====&lt;br /&gt;
Install via Git bash&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install -g karma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step by step Testing Procedure===&lt;br /&gt;
Create Test Folder&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir spec/javascripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write Tests&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# spec/javascripts/controllers_spec.js.coffee&lt;br /&gt;
&lt;br /&gt;
describe &amp;quot;Restauranteur controllers&amp;quot;, -&amp;gt;&lt;br /&gt;
  beforeEach module(&amp;quot;restauranteur&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;RestaurantIndexCtrl&amp;quot;, -&amp;gt;&lt;br /&gt;
    it &amp;quot;should set restaurants to an empty array&amp;quot;, inject(($controller) -&amp;gt;&lt;br /&gt;
      scope = {}&lt;br /&gt;
      ctrl = $controller(&amp;quot;RestaurantIndexCtrl&amp;quot;,&lt;br /&gt;
        $scope: scope&lt;br /&gt;
      )&lt;br /&gt;
      expect(scope.restaurants.length).toBe 0&lt;br /&gt;
    )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Configurations&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&lt;br /&gt;
module.exports = function(config) {&lt;br /&gt;
  config.set({&lt;br /&gt;
    basePath: '../..',&lt;br /&gt;
&lt;br /&gt;
    frameworks: ['jasmine'],&lt;br /&gt;
&lt;br /&gt;
    autoWatch: true,&lt;br /&gt;
&lt;br /&gt;
    preprocessors: {&lt;br /&gt;
      '**/*.coffee': 'coffee'&lt;br /&gt;
    }, &lt;br /&gt;
&lt;br /&gt;
    files: [&lt;br /&gt;
      'app/assets/javascripts/angular.js',&lt;br /&gt;
      'app/assets/javascripts/angular-mocks.js',&lt;br /&gt;
      'app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee',&lt;br /&gt;
      'app/assets/javascripts/angular/*',&lt;br /&gt;
      'spec/javascripts/*_spec.js.coffee'&lt;br /&gt;
    ]  &lt;br /&gt;
  });&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Karma Server&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
karma start spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to go to http://localhost:9876/ and test will run and be successful.&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89595</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89595"/>
		<updated>2014-10-15T04:28:13Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Why AngularJS + Rails? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration.&amp;lt;ref&amp;gt;https://www.codeschool.com/courses/shaping-up-with-angular-js&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started&amp;lt;ref&amp;gt;http://sebastien.saunier.me/blog/2014/02/04/angular--rails-with-no-fuss.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: Restauranteur &amp;lt;ref&amp;gt;http://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finally Seed the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/seeds.rb&lt;br /&gt;
&lt;br /&gt;
Restaurant.create([&lt;br /&gt;
  { name: &amp;quot;The French Laundry&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Chez Panisse&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Bouchon&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Noma&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Taco Bell&amp;quot; },&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own '''Controller'''. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller '''HomeCtrl'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 4: Create Templates and Modify Controller ===&lt;br /&gt;
&lt;br /&gt;
Make changes in the layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make template for restaurants (this can be created anywhere), we are making it under public directory and create and index page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- public/templates/restaurants/index.html --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;/#&amp;quot;&amp;gt;index&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;ul ng-repeat=&amp;quot;restaurant in restaurants&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&amp;lt;a ng-click=&amp;quot;viewRestaurant(restaurant.id)&amp;quot;&amp;gt;{{ restaurant.name }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
create Restaurant Index Controller&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'RestaurantIndexCtrl', ['$scope', '$location', '$http', ($scope, $location, $http) -&amp;gt;&lt;br /&gt;
  $scope.restaurants = []&lt;br /&gt;
  $http.get('./restaurants.json').success((data) -&amp;gt;&lt;br /&gt;
    $scope.restaurants = data&lt;br /&gt;
  )&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 5: Adjust Routing in main.js===&lt;br /&gt;
&lt;br /&gt;
Now modify routing so that new Restaurant Index page is called.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/main.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur = angular.module('restauranteur', [])&lt;br /&gt;
&lt;br /&gt;
@restauranteur.config(['$routeProvider', ($routeProvider) -&amp;gt;&lt;br /&gt;
  $routeProvider.&lt;br /&gt;
    when('/restaurants', {&lt;br /&gt;
      templateUrl: '../templates/restaurants/index.html',&lt;br /&gt;
      controller: 'RestaurantIndexCtrl'&lt;br /&gt;
    })&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's done! Now go to URI /#/restaurants to see list of Restaurants we added.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
For testing we are going to use Rspec, Karma, and Jasmine framework. We start by first installing Karma server:&lt;br /&gt;
&lt;br /&gt;
====For Ubuntu====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo npm install -g karma&lt;br /&gt;
sudo npm install -g karma-ng-scenario&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====For Windows====&lt;br /&gt;
Install via Git bash&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install -g karma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step by step Testing Procedure===&lt;br /&gt;
Create Test Folder&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir spec/javascripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write Tests&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# spec/javascripts/controllers_spec.js.coffee&lt;br /&gt;
&lt;br /&gt;
describe &amp;quot;Restauranteur controllers&amp;quot;, -&amp;gt;&lt;br /&gt;
  beforeEach module(&amp;quot;restauranteur&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;RestaurantIndexCtrl&amp;quot;, -&amp;gt;&lt;br /&gt;
    it &amp;quot;should set restaurants to an empty array&amp;quot;, inject(($controller) -&amp;gt;&lt;br /&gt;
      scope = {}&lt;br /&gt;
      ctrl = $controller(&amp;quot;RestaurantIndexCtrl&amp;quot;,&lt;br /&gt;
        $scope: scope&lt;br /&gt;
      )&lt;br /&gt;
      expect(scope.restaurants.length).toBe 0&lt;br /&gt;
    )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Configurations&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&lt;br /&gt;
module.exports = function(config) {&lt;br /&gt;
  config.set({&lt;br /&gt;
    basePath: '../..',&lt;br /&gt;
&lt;br /&gt;
    frameworks: ['jasmine'],&lt;br /&gt;
&lt;br /&gt;
    autoWatch: true,&lt;br /&gt;
&lt;br /&gt;
    preprocessors: {&lt;br /&gt;
      '**/*.coffee': 'coffee'&lt;br /&gt;
    }, &lt;br /&gt;
&lt;br /&gt;
    files: [&lt;br /&gt;
      'app/assets/javascripts/angular.js',&lt;br /&gt;
      'app/assets/javascripts/angular-mocks.js',&lt;br /&gt;
      'app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee',&lt;br /&gt;
      'app/assets/javascripts/angular/*',&lt;br /&gt;
      'spec/javascripts/*_spec.js.coffee'&lt;br /&gt;
    ]  &lt;br /&gt;
  });&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Karma Server&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
karma start spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to go to http://localhost:9876/ and test will run and be successful.&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89594</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89594"/>
		<updated>2014-10-15T04:25:15Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Step 1: Creating Base Rails app */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started&amp;lt;ref&amp;gt;http://sebastien.saunier.me/blog/2014/02/04/angular--rails-with-no-fuss.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: Restauranteur &amp;lt;ref&amp;gt;http://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finally Seed the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/seeds.rb&lt;br /&gt;
&lt;br /&gt;
Restaurant.create([&lt;br /&gt;
  { name: &amp;quot;The French Laundry&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Chez Panisse&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Bouchon&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Noma&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Taco Bell&amp;quot; },&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own '''Controller'''. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller '''HomeCtrl'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 4: Create Templates and Modify Controller ===&lt;br /&gt;
&lt;br /&gt;
Make changes in the layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make template for restaurants (this can be created anywhere), we are making it under public directory and create and index page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- public/templates/restaurants/index.html --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;/#&amp;quot;&amp;gt;index&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;ul ng-repeat=&amp;quot;restaurant in restaurants&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&amp;lt;a ng-click=&amp;quot;viewRestaurant(restaurant.id)&amp;quot;&amp;gt;{{ restaurant.name }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
create Restaurant Index Controller&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'RestaurantIndexCtrl', ['$scope', '$location', '$http', ($scope, $location, $http) -&amp;gt;&lt;br /&gt;
  $scope.restaurants = []&lt;br /&gt;
  $http.get('./restaurants.json').success((data) -&amp;gt;&lt;br /&gt;
    $scope.restaurants = data&lt;br /&gt;
  )&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 5: Adjust Routing in main.js===&lt;br /&gt;
&lt;br /&gt;
Now modify routing so that new Restaurant Index page is called.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/main.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur = angular.module('restauranteur', [])&lt;br /&gt;
&lt;br /&gt;
@restauranteur.config(['$routeProvider', ($routeProvider) -&amp;gt;&lt;br /&gt;
  $routeProvider.&lt;br /&gt;
    when('/restaurants', {&lt;br /&gt;
      templateUrl: '../templates/restaurants/index.html',&lt;br /&gt;
      controller: 'RestaurantIndexCtrl'&lt;br /&gt;
    })&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's done! Now go to URI /#/restaurants to see list of Restaurants we added.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
For testing we are going to use Rspec, Karma, and Jasmine framework. We start by first installing Karma server:&lt;br /&gt;
&lt;br /&gt;
====For Ubuntu====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo npm install -g karma&lt;br /&gt;
sudo npm install -g karma-ng-scenario&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====For Windows====&lt;br /&gt;
Install via Git bash&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install -g karma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step by step Testing Procedure===&lt;br /&gt;
Create Test Folder&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir spec/javascripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write Tests&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# spec/javascripts/controllers_spec.js.coffee&lt;br /&gt;
&lt;br /&gt;
describe &amp;quot;Restauranteur controllers&amp;quot;, -&amp;gt;&lt;br /&gt;
  beforeEach module(&amp;quot;restauranteur&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;RestaurantIndexCtrl&amp;quot;, -&amp;gt;&lt;br /&gt;
    it &amp;quot;should set restaurants to an empty array&amp;quot;, inject(($controller) -&amp;gt;&lt;br /&gt;
      scope = {}&lt;br /&gt;
      ctrl = $controller(&amp;quot;RestaurantIndexCtrl&amp;quot;,&lt;br /&gt;
        $scope: scope&lt;br /&gt;
      )&lt;br /&gt;
      expect(scope.restaurants.length).toBe 0&lt;br /&gt;
    )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Configurations&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&lt;br /&gt;
module.exports = function(config) {&lt;br /&gt;
  config.set({&lt;br /&gt;
    basePath: '../..',&lt;br /&gt;
&lt;br /&gt;
    frameworks: ['jasmine'],&lt;br /&gt;
&lt;br /&gt;
    autoWatch: true,&lt;br /&gt;
&lt;br /&gt;
    preprocessors: {&lt;br /&gt;
      '**/*.coffee': 'coffee'&lt;br /&gt;
    }, &lt;br /&gt;
&lt;br /&gt;
    files: [&lt;br /&gt;
      'app/assets/javascripts/angular.js',&lt;br /&gt;
      'app/assets/javascripts/angular-mocks.js',&lt;br /&gt;
      'app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee',&lt;br /&gt;
      'app/assets/javascripts/angular/*',&lt;br /&gt;
      'spec/javascripts/*_spec.js.coffee'&lt;br /&gt;
    ]  &lt;br /&gt;
  });&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Karma Server&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
karma start spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to go to http://localhost:9876/ and test will run and be successful.&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89478</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89478"/>
		<updated>2014-10-07T05:56:48Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [http://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finally Seed the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/seeds.rb&lt;br /&gt;
&lt;br /&gt;
Restaurant.create([&lt;br /&gt;
  { name: &amp;quot;The French Laundry&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Chez Panisse&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Bouchon&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Noma&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Taco Bell&amp;quot; },&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own '''Controller'''. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller '''HomeCtrl'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 4: Create Templates and Modify Controller ===&lt;br /&gt;
&lt;br /&gt;
Make changes in the layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make template for restaurants (this can be created anywhere), we are making it under public directory and create and index page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- public/templates/restaurants/index.html --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;/#&amp;quot;&amp;gt;index&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;ul ng-repeat=&amp;quot;restaurant in restaurants&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&amp;lt;a ng-click=&amp;quot;viewRestaurant(restaurant.id)&amp;quot;&amp;gt;{{ restaurant.name }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
create Restaurant Index Controller&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'RestaurantIndexCtrl', ['$scope', '$location', '$http', ($scope, $location, $http) -&amp;gt;&lt;br /&gt;
  $scope.restaurants = []&lt;br /&gt;
  $http.get('./restaurants.json').success((data) -&amp;gt;&lt;br /&gt;
    $scope.restaurants = data&lt;br /&gt;
  )&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 5: Adjust Routing in main.js===&lt;br /&gt;
&lt;br /&gt;
Now modify routing so that new Restaurant Index page is called.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/main.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur = angular.module('restauranteur', [])&lt;br /&gt;
&lt;br /&gt;
@restauranteur.config(['$routeProvider', ($routeProvider) -&amp;gt;&lt;br /&gt;
  $routeProvider.&lt;br /&gt;
    when('/restaurants', {&lt;br /&gt;
      templateUrl: '../templates/restaurants/index.html',&lt;br /&gt;
      controller: 'RestaurantIndexCtrl'&lt;br /&gt;
    })&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's done! Now go to URI /#/restaurants to see list of Restaurants we added.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
For testing we are going to use Rspec, Karma, and Jasmine framework. We start by first installing Karma server:&lt;br /&gt;
&lt;br /&gt;
====For Ubuntu====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo npm install -g karma&lt;br /&gt;
sudo npm install -g karma-ng-scenario&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====For Windows====&lt;br /&gt;
Install via Git bash&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install -g karma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step by step Testing Procedure===&lt;br /&gt;
Create Test Folder&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir spec/javascripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write Tests&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# spec/javascripts/controllers_spec.js.coffee&lt;br /&gt;
&lt;br /&gt;
describe &amp;quot;Restauranteur controllers&amp;quot;, -&amp;gt;&lt;br /&gt;
  beforeEach module(&amp;quot;restauranteur&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;RestaurantIndexCtrl&amp;quot;, -&amp;gt;&lt;br /&gt;
    it &amp;quot;should set restaurants to an empty array&amp;quot;, inject(($controller) -&amp;gt;&lt;br /&gt;
      scope = {}&lt;br /&gt;
      ctrl = $controller(&amp;quot;RestaurantIndexCtrl&amp;quot;,&lt;br /&gt;
        $scope: scope&lt;br /&gt;
      )&lt;br /&gt;
      expect(scope.restaurants.length).toBe 0&lt;br /&gt;
    )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Configurations&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&lt;br /&gt;
module.exports = function(config) {&lt;br /&gt;
  config.set({&lt;br /&gt;
    basePath: '../..',&lt;br /&gt;
&lt;br /&gt;
    frameworks: ['jasmine'],&lt;br /&gt;
&lt;br /&gt;
    autoWatch: true,&lt;br /&gt;
&lt;br /&gt;
    preprocessors: {&lt;br /&gt;
      '**/*.coffee': 'coffee'&lt;br /&gt;
    }, &lt;br /&gt;
&lt;br /&gt;
    files: [&lt;br /&gt;
      'app/assets/javascripts/angular.js',&lt;br /&gt;
      'app/assets/javascripts/angular-mocks.js',&lt;br /&gt;
      'app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee',&lt;br /&gt;
      'app/assets/javascripts/angular/*',&lt;br /&gt;
      'spec/javascripts/*_spec.js.coffee'&lt;br /&gt;
    ]  &lt;br /&gt;
  });&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Karma Server&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
karma start spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to go to http://localhost:9876/ and test will run and be successful.&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89477</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89477"/>
		<updated>2014-10-07T05:54:29Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [http://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finally Seed the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/seeds.rb&lt;br /&gt;
&lt;br /&gt;
Restaurant.create([&lt;br /&gt;
  { name: &amp;quot;The French Laundry&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Chez Panisse&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Bouchon&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Noma&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Taco Bell&amp;quot; },&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own '''Controller'''. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller '''HomeCtrl'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 4: Create Templates and Modify Controller ===&lt;br /&gt;
&lt;br /&gt;
Make changes in the layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make template for restaurants (this can be created anywhere), we are making it under public directory and create and index page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- public/templates/restaurants/index.html --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;/#&amp;quot;&amp;gt;index&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;ul ng-repeat=&amp;quot;restaurant in restaurants&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&amp;lt;a ng-click=&amp;quot;viewRestaurant(restaurant.id)&amp;quot;&amp;gt;{{ restaurant.name }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
create Restaurant Index Controller&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'RestaurantIndexCtrl', ['$scope', '$location', '$http', ($scope, $location, $http) -&amp;gt;&lt;br /&gt;
  $scope.restaurants = []&lt;br /&gt;
  $http.get('./restaurants.json').success((data) -&amp;gt;&lt;br /&gt;
    $scope.restaurants = data&lt;br /&gt;
  )&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 5: Adjust Routing in main.js===&lt;br /&gt;
&lt;br /&gt;
Now modify routing so that new Restaurant Index page is called.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/main.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur = angular.module('restauranteur', [])&lt;br /&gt;
&lt;br /&gt;
@restauranteur.config(['$routeProvider', ($routeProvider) -&amp;gt;&lt;br /&gt;
  $routeProvider.&lt;br /&gt;
    when('/restaurants', {&lt;br /&gt;
      templateUrl: '../templates/restaurants/index.html',&lt;br /&gt;
      controller: 'RestaurantIndexCtrl'&lt;br /&gt;
    })&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's done! Now go to URI /#/restaurants to see list of Restaurants we added.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
For testing we are going to use Rspec, Karma, and Jasmine framework. We start by first installing Karma server:&lt;br /&gt;
&lt;br /&gt;
===For Ubuntu===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo npm install -g karma&lt;br /&gt;
sudo npm install -g karma-ng-scenario&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===For Windows===&lt;br /&gt;
Install via Git bash&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install -g karma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create Test Folder===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir spec/javascripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Write Tests===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# spec/javascripts/controllers_spec.js.coffee&lt;br /&gt;
&lt;br /&gt;
describe &amp;quot;Restauranteur controllers&amp;quot;, -&amp;gt;&lt;br /&gt;
  beforeEach module(&amp;quot;restauranteur&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;RestaurantIndexCtrl&amp;quot;, -&amp;gt;&lt;br /&gt;
    it &amp;quot;should set restaurants to an empty array&amp;quot;, inject(($controller) -&amp;gt;&lt;br /&gt;
      scope = {}&lt;br /&gt;
      ctrl = $controller(&amp;quot;RestaurantIndexCtrl&amp;quot;,&lt;br /&gt;
        $scope: scope&lt;br /&gt;
      )&lt;br /&gt;
      expect(scope.restaurants.length).toBe 0&lt;br /&gt;
    )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add Configurations===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&lt;br /&gt;
module.exports = function(config) {&lt;br /&gt;
  config.set({&lt;br /&gt;
    basePath: '../..',&lt;br /&gt;
&lt;br /&gt;
    frameworks: ['jasmine'],&lt;br /&gt;
&lt;br /&gt;
    autoWatch: true,&lt;br /&gt;
&lt;br /&gt;
    preprocessors: {&lt;br /&gt;
      '**/*.coffee': 'coffee'&lt;br /&gt;
    }, &lt;br /&gt;
&lt;br /&gt;
    files: [&lt;br /&gt;
      'app/assets/javascripts/angular.js',&lt;br /&gt;
      'app/assets/javascripts/angular-mocks.js',&lt;br /&gt;
      'app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee',&lt;br /&gt;
      'app/assets/javascripts/angular/*',&lt;br /&gt;
      'spec/javascripts/*_spec.js.coffee'&lt;br /&gt;
    ]  &lt;br /&gt;
  });&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Start Karma Server===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
karma start spec/javascripts/restauranteur.conf.js&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to go to http://localhost:9876/ and test will run and be successful.&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89476</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89476"/>
		<updated>2014-10-07T05:40:56Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* AngularJS + Rails */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [http://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finally Seed the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/seeds.rb&lt;br /&gt;
&lt;br /&gt;
Restaurant.create([&lt;br /&gt;
  { name: &amp;quot;The French Laundry&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Chez Panisse&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Bouchon&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Noma&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Taco Bell&amp;quot; },&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own '''Controller'''. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller '''HomeCtrl'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 4: Create Templates and Modify Controller ===&lt;br /&gt;
&lt;br /&gt;
Make changes in the layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make template for restaurants (this can be created anywhere), we are making it under public directory and create and index page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- public/templates/restaurants/index.html --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;/#&amp;quot;&amp;gt;index&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;ul ng-repeat=&amp;quot;restaurant in restaurants&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&amp;lt;a ng-click=&amp;quot;viewRestaurant(restaurant.id)&amp;quot;&amp;gt;{{ restaurant.name }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
create Restaurant Index Controller&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'RestaurantIndexCtrl', ['$scope', '$location', '$http', ($scope, $location, $http) -&amp;gt;&lt;br /&gt;
  $scope.restaurants = []&lt;br /&gt;
  $http.get('./restaurants.json').success((data) -&amp;gt;&lt;br /&gt;
    $scope.restaurants = data&lt;br /&gt;
  )&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 5: Adjust Routing in main.js===&lt;br /&gt;
&lt;br /&gt;
Now modify routing so that new Restaurant Index page is called.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/main.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur = angular.module('restauranteur', [])&lt;br /&gt;
&lt;br /&gt;
@restauranteur.config(['$routeProvider', ($routeProvider) -&amp;gt;&lt;br /&gt;
  $routeProvider.&lt;br /&gt;
    when('/restaurants', {&lt;br /&gt;
      templateUrl: '../templates/restaurants/index.html',&lt;br /&gt;
      controller: 'RestaurantIndexCtrl'&lt;br /&gt;
    })&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's done! Now go to URI /#/restaurants to see list of Restaurants we added.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89475</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89475"/>
		<updated>2014-10-07T05:39:55Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Getting Started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [http://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finally Seed the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/seeds.rb&lt;br /&gt;
&lt;br /&gt;
Restaurant.create([&lt;br /&gt;
  { name: &amp;quot;The French Laundry&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Chez Panisse&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Bouchon&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Noma&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Taco Bell&amp;quot; },&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own '''Controller'''. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller '''HomeCtrl'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 4: Create Templates and Modify Controller ===&lt;br /&gt;
&lt;br /&gt;
Make changes in the layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make template for restaurants (this can be created anywhere), we are making it under public directory and create and index page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- public/templates/restaurants/index.html --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;/#&amp;quot;&amp;gt;index&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;ul ng-repeat=&amp;quot;restaurant in restaurants&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&amp;lt;a ng-click=&amp;quot;viewRestaurant(restaurant.id)&amp;quot;&amp;gt;{{ restaurant.name }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
create Restaurant Index Controller&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'RestaurantIndexCtrl', ['$scope', '$location', '$http', ($scope, $location, $http) -&amp;gt;&lt;br /&gt;
  $scope.restaurants = []&lt;br /&gt;
  $http.get('./restaurants.json').success((data) -&amp;gt;&lt;br /&gt;
    $scope.restaurants = data&lt;br /&gt;
  )&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 5: Adjust Routing in main.js===&lt;br /&gt;
&lt;br /&gt;
Now modify routing so that new Restaurant Index page is called.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/main.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur = angular.module('restauranteur', [])&lt;br /&gt;
&lt;br /&gt;
@restauranteur.config(['$routeProvider', ($routeProvider) -&amp;gt;&lt;br /&gt;
  $routeProvider.&lt;br /&gt;
    when('/restaurants', {&lt;br /&gt;
      templateUrl: '../templates/restaurants/index.html',&lt;br /&gt;
      controller: 'RestaurantIndexCtrl'&lt;br /&gt;
    })&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's done! Now go to URI /#/restaurants to see list of Restaurants we added.&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89474</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89474"/>
		<updated>2014-10-07T05:39:27Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Getting Started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [https://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finally Seed the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/seeds.rb&lt;br /&gt;
&lt;br /&gt;
Restaurant.create([&lt;br /&gt;
  { name: &amp;quot;The French Laundry&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Chez Panisse&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Bouchon&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Noma&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Taco Bell&amp;quot; },&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own '''Controller'''. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller '''HomeCtrl'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 4: Create Templates and Modify Controller ===&lt;br /&gt;
&lt;br /&gt;
Make changes in the layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make template for restaurants (this can be created anywhere), we are making it under public directory and create and index page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- public/templates/restaurants/index.html --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;/#&amp;quot;&amp;gt;index&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;ul ng-repeat=&amp;quot;restaurant in restaurants&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&amp;lt;a ng-click=&amp;quot;viewRestaurant(restaurant.id)&amp;quot;&amp;gt;{{ restaurant.name }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
create Restaurant Index Controller&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'RestaurantIndexCtrl', ['$scope', '$location', '$http', ($scope, $location, $http) -&amp;gt;&lt;br /&gt;
  $scope.restaurants = []&lt;br /&gt;
  $http.get('./restaurants.json').success((data) -&amp;gt;&lt;br /&gt;
    $scope.restaurants = data&lt;br /&gt;
  )&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 5: Adjust Routing in main.js===&lt;br /&gt;
&lt;br /&gt;
Now modify routing so that new Restaurant Index page is called.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/main.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur = angular.module('restauranteur', [])&lt;br /&gt;
&lt;br /&gt;
@restauranteur.config(['$routeProvider', ($routeProvider) -&amp;gt;&lt;br /&gt;
  $routeProvider.&lt;br /&gt;
    when('/restaurants', {&lt;br /&gt;
      templateUrl: '../templates/restaurants/index.html',&lt;br /&gt;
      controller: 'RestaurantIndexCtrl'&lt;br /&gt;
    })&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's done! Now go to URI /#/restaurants to see list of Restaurants we added.&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89473</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89473"/>
		<updated>2014-10-07T05:36:01Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Getting Started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [https://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails/ Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finally Seed the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/seeds.rb&lt;br /&gt;
&lt;br /&gt;
Restaurant.create([&lt;br /&gt;
  { name: &amp;quot;The French Laundry&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Chez Panisse&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Bouchon&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Noma&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Taco Bell&amp;quot; },&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own '''Controller'''. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller '''HomeCtrl'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 4: Create Templates and Modify Controller ===&lt;br /&gt;
&lt;br /&gt;
Make changes in the layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make template for restaurants (this can be created anywhere), we are making it under public directory and create and index page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- public/templates/restaurants/index.html --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;/#&amp;quot;&amp;gt;index&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;ul ng-repeat=&amp;quot;restaurant in restaurants&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&amp;lt;a ng-click=&amp;quot;viewRestaurant(restaurant.id)&amp;quot;&amp;gt;{{ restaurant.name }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
create Restaurant Index Controller&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/RestaurantIndexCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'RestaurantIndexCtrl', ['$scope', '$location', '$http', ($scope, $location, $http) -&amp;gt;&lt;br /&gt;
  $scope.restaurants = []&lt;br /&gt;
  $http.get('./restaurants.json').success((data) -&amp;gt;&lt;br /&gt;
    $scope.restaurants = data&lt;br /&gt;
  )&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 5: Adjust Routing in main.js===&lt;br /&gt;
&lt;br /&gt;
Now modify routing so that new Restaurant Index page is called.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/main.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur = angular.module('restauranteur', [])&lt;br /&gt;
&lt;br /&gt;
@restauranteur.config(['$routeProvider', ($routeProvider) -&amp;gt;&lt;br /&gt;
  $routeProvider.&lt;br /&gt;
    when('/restaurants', {&lt;br /&gt;
      templateUrl: '../templates/restaurants/index.html',&lt;br /&gt;
      controller: 'RestaurantIndexCtrl'&lt;br /&gt;
    })&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's done! Now go to URI /#/restaurants to see list of Restaurants we added.&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89472</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89472"/>
		<updated>2014-10-07T05:24:54Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Step 3: Introduce AngularJS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [https://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails/ Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finally Seed the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/seeds.rb&lt;br /&gt;
&lt;br /&gt;
Restaurant.create([&lt;br /&gt;
  { name: &amp;quot;The French Laundry&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Chez Panisse&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Bouchon&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Noma&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Taco Bell&amp;quot; },&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own '''Controller'''. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller '''HomeCtrl'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
make changes to layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89471</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89471"/>
		<updated>2014-10-07T05:24:18Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Step 2: Creating the Restaurant model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [https://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails/ Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finally Seed the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/seeds.rb&lt;br /&gt;
&lt;br /&gt;
Restaurant.create([&lt;br /&gt;
  { name: &amp;quot;The French Laundry&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Chez Panisse&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Bouchon&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Noma&amp;quot; },&lt;br /&gt;
  { name: &amp;quot;Taco Bell&amp;quot; },&lt;br /&gt;
])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own Controller. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller HomeCtrl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
make changes to layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89470</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89470"/>
		<updated>2014-10-07T05:22:18Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Step 3: Introduce AngularJS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [https://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails/ Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own Controller. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller HomeCtrl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
make changes to layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89469</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89469"/>
		<updated>2014-10-07T05:21:42Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Step 3: Introduce AngularJS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [https://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails/ Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own Controller. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller HomeCtrl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
make changes to layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89468</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89468"/>
		<updated>2014-10-07T05:21:26Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Step 3: Introduce AngularJS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [https://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails/ Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own Controller. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller HomeCtrl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
make changes to layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89467</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89467"/>
		<updated>2014-10-07T05:21:02Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Step 3: Introduce AngularJS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [https://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails/ Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own Controller. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller HomeCtrl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- app/views/layouts/application.html.erb --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
make changes to layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89466</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89466"/>
		<updated>2014-10-07T05:20:23Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Step 3: Introduce AngularJS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [https://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails/ Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own Controller. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller HomeCtrl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
make changes to layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;         ==&amp;gt;   &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt;   ==&amp;gt;   &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89465</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89465"/>
		<updated>2014-10-07T05:19:47Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Step 3: Introduce AngularJS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [https://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails/ Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own Controller. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller HomeCtrl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
make changes to layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt; '''==&amp;gt;''' &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt; '''==&amp;gt;''' &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89464</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89464"/>
		<updated>2014-10-07T05:19:23Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Step 3: Introduce AngularJS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [https://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails/ Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own Controller. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller HomeCtrl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
make changes to layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt; &amp;lt;b&amp;gt;==&amp;gt;&amp;lt;/b&amp;gt; &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt; &amp;lt;b&amp;gt;==&amp;gt;&amp;lt;/b&amp;gt; &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89463</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89463"/>
		<updated>2014-10-07T05:18:45Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Getting Started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [https://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails/ Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own Controller. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller HomeCtrl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
make changes to layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt; ==&amp;gt; &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt; ==&amp;gt; &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89462</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89462"/>
		<updated>2014-10-07T05:18:24Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Step 3: Introduce AngularJS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [https://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails/ Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own Controller. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller HomeCtrl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
make changes to layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt; ==&amp;gt; &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt; ==&amp;gt; &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89461</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89461"/>
		<updated>2014-10-07T05:17:48Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Step 2: Creating the Restaurant model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [https://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails/ Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own Controller. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller HomeCtrl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make Changes to layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt; ==&amp;gt; &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt; ==&amp;gt; &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89460</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89460"/>
		<updated>2014-10-07T05:17:05Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Getting Started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [https://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails/ Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then Run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 3: Introduce AngularJS ===&lt;br /&gt;
Now we need to make use of the downloaded AngularJS, and move the files into app/assets/javascripts.&lt;br /&gt;
&lt;br /&gt;
Add it to Asset Pipeline, to tell our application we need AngularJs and to make sure it gets loaded before other dependent files. Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//= require angular&lt;br /&gt;
//= require main&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, AngularJS being an MVC framework requires its own Controller. Now we will create controller for it in directory /assets/javascripts/angular/controllers. Let's call the controller HomeCtrl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# app/assets/javascripts/angular/controllers/HomeCtrl.js.coffee&lt;br /&gt;
&lt;br /&gt;
@restauranteur.controller 'HomeCtrl', ['$scope', ($scope) -&amp;gt;&lt;br /&gt;
  # Notice how this controller body is empty&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make Changes to layout:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt; ==&amp;gt; &amp;lt;html ng-app=&amp;quot;restauranteur&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= yield %&amp;gt; ==&amp;gt; &amp;lt;div ng-view&amp;gt; &amp;lt;%= yield %&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89459</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 34 kr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_34_kr&amp;diff=89459"/>
		<updated>2014-10-07T05:03:48Z</updated>

		<summary type="html">&lt;p&gt;Rarora4: /* Getting Started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''AngularJS + Rails''' =&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
[http://angularjs.org// AngularJS] is an [http://en.wikipedia.org/wiki/Open_source open source] client-side [http://en.wikipedia.org/wiki/JavaScript Javascript] framework for creating web applications with [http://en.wikipedia.org/wiki/Dynamic_web_page dynamic web pages] and is maintained by [http://www.google.com/ Google]. AngularJS has extended [http://en.wikipedia.org/wiki/HTML HTML's] syntax and implemented it with [http://mrbool.com/mvc-in-angularjs/28962 Model-View-Controller] architecture so that the various components of Javascript can be expressed clearly. It provides functionalities like [http://docs.angularjs.org/guide/databinding data binding] and [http://docs.angularjs.org/guide/di dependency injection] which helps shorten the crude javascript code. It has a simple [http://en.wikipedia.org/wiki/Object_model object model] that supports testability and clean code organization.&lt;br /&gt;
&lt;br /&gt;
[http://rubyonrails.org/ Rails] is an open source web application framework written in [http://www.ruby-lang.org/en/ Ruby] by David Heinemeier Hansson. It is extremely productive for developing database-backed web applications. It uses Model-View-Controller architecture and requires fewer total lines of code than other frameworks thus making it atleast ten times faster.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;float:{{{align|right}}}&amp;quot;&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; |[[File:angularjs+rails.jpg|center|AngularJS + Rails&amp;lt;ref&amp;gt;http://rigor.com/wp-content/uploads/2014/09/angularjs+rails.jpg&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
|-&lt;br /&gt;
|'''Name'''||[http://angularjs.org// AngularJS] + [http://rubyonrails.org/ Rails]&lt;br /&gt;
|-&lt;br /&gt;
|'''Category'''||[http://en.wikipedia.org/wiki/Open-source_software Open Source Software]&lt;br /&gt;
|-&lt;br /&gt;
|'''Type'''||[http://en.wikipedia.org/wiki/Web_application_framework Web Application Framework]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
===AngularJS===&lt;br /&gt;
&lt;br /&gt;
AngularJS was developed by Misko Hevery and Adam Abrons at Brat Tech LLC in 2009 as the software behind an oline JSON storage service. Later, it was released as an open source library. The library is being developed and maintained by Hevery with his fellow Google employees.&lt;br /&gt;
&lt;br /&gt;
===Rails===&lt;br /&gt;
Rails was extracted from Basecamp, a project management tool by 37signals but it was released as an open source project in July 2004. It gained fame after Apple decided to ship it with Mac OS X, which was released in October 2007.&lt;br /&gt;
&lt;br /&gt;
==Why AngularJS + Rails?==&lt;br /&gt;
&lt;br /&gt;
One of the key reasons of using AngularJs is API-Driven Application approach, i.e. separation of User Interface from back-end (Rails in our case). Increasing number of application these days (Rails Application) are building their own APIs which can they interface with mobile applications (like iOS), or other developer applications can communicate with their applications, and in our case to communicate with front-end applications.  By following this paradigm, developers gets an opportunity to build a front-end as well as back-end APIs along with your application, it means front-end exposes its methods to the JSON API in the back-end and the front-end API can be clubbed with any back-end and vice-versa without any need for re-configuration. &lt;br /&gt;
&lt;br /&gt;
So the question is why to club AngularJS with Rails and what are its advantages? AngularJS is a front-end framework, what this means is, it is designed to run on the client side, therefore for any real application requiring CRUD operations a back-end is necessary. This is where Rails comes into picture, it provides a back-end to the AngularJS application so that large amount of data can be stored in database. Another issue with using standalone AngularJS application is that it creates Single-page Applications (SPA), i.e. the same page or components on the page gets refreshed, which makes [http://en.wikipedia.org/wiki/Search_engine_optimization Search Engine Optimization] extremely tricky, as a result the possibility of making the web page searchable reduces drastically. Whereas in case of Rails the web pages are rendered by Rails on the server, which makes them available to Google for SEO based search.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Following are the pre-requisites for learning AngularJS:&lt;br /&gt;
# Moderate knowledge of HTML, JavaScript and CSS.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
# The [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model].&lt;br /&gt;
# JavaScript functions, events, and error handling.&lt;br /&gt;
&lt;br /&gt;
=====Rails=====&lt;br /&gt;
&lt;br /&gt;
# Comprehensive knowledge of Ruby.&lt;br /&gt;
# Moderate knowledge of databases.&lt;br /&gt;
# Basic Model-View-Controller concepts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Download AngularJS===&lt;br /&gt;
&lt;br /&gt;
Download AngularJS from [https://angularjs.org/ AngularJS] website. We need to download file: angular-mocks.js&lt;br /&gt;
&lt;br /&gt;
===Step 1: Creating Base Rails app===&lt;br /&gt;
&lt;br /&gt;
We will start with creating a basic Rails application that performs CRUD operations. We shall use PostgreSQL and Rspec here.&lt;br /&gt;
&lt;br /&gt;
Lets call this application: [https://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails/ Restauranteur]&lt;br /&gt;
&lt;br /&gt;
====Initial Setup====&lt;br /&gt;
To create project:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails new restauranteur --database=postgresql --skip-test-unit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create PostgresSQL user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ createuser -P -s -e restauranteur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add Rspec to your Gemfile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;~&amp;gt; 2.14.0&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Rspec&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ bundle install&lt;br /&gt;
$ rails g rspec:install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the database:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:create&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2: Creating the Restaurant model===&lt;br /&gt;
Our next step is to create a model class in Rails&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rails generate scaffold restaurant name:string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that Restaurant Names are unique:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# db/migrate/[timestamp]_create_restaurants.rb&lt;br /&gt;
&lt;br /&gt;
class CreateRestaurants &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    create_table :restaurants do |t|&lt;br /&gt;
      t.string :name&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # Add the following line&lt;br /&gt;
    add_index :restaurants, :name, unique: true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this in Model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Restaurant &amp;lt; ActiveRecord::Base &lt;br /&gt;
  validates :name, presence: true, uniqueness: { case_sensitive: false }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then Run Migration&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Comparison with other front-end frameworks==&lt;br /&gt;
&lt;br /&gt;
The most popular front end frameworks these days include AngularJS, [http://backbonejs.org/ BackboneJS] and [http://emberjs.com/ EmberJS]. These can be compared on the basis of the following factors&amp;lt;ref&amp;gt;http://www.airpair.com/js/javascript-framework-comparison&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Community is the most important factor to consider when choosing a framework as a strong and large community means strong support and help towards the framework. More questions will be answered, more tutorials will be available. In short, larger the community means more the number of resources to exploit. &lt;br /&gt;
&lt;br /&gt;
So, if compared on the basis of community, AngularJS is the clear winner as there are more [http://stackoverflow.com/questions/tagged/angularjs StackOverflow questions] , [https://www.youtube.com/user/angularjs YouTube tutorials], [http://github.com/ GitHub] Contributors available for Angular then the rest of the frameworks. Also, in the recent years AngularJS has gained more and more popularity compared to the other two.&lt;br /&gt;
&lt;br /&gt;
===Framework Size===&lt;br /&gt;
&lt;br /&gt;
For a website to be successful, it should have good page load speed as users these days need good speed of browsing. In order to load pages fast, the front end framework should be as small as possible so that they can be loaded faster. &lt;br /&gt;
If we compare the sizes of the frameworks, BackboneJS (6.5 kb) is the smallest among AngularJS(39.5 kb) and EmberJS(90 kb). But, BackboneJS needs UnderscoreJS(5 kb) and jQuery(32 kb) along with some other third party plugins which makes the size large. &lt;br /&gt;
Thus, AngularJS is the clear winner among these frameworks.&lt;br /&gt;
&lt;br /&gt;
===Templating===&lt;br /&gt;
&lt;br /&gt;
Front end frameworks generally use different kind of templates to style their code in a specific way. There are many kinds of [http://www.creativebloq.com/web-design/templating-engines-9134396 templates] available that an be used. &lt;br /&gt;
BackboneJS doesn't provide any templating engine of its own but AngularJS and EmberJS have there own templating system. The difference between the templating engines of the three frameworks can be understood from the following examples :&lt;br /&gt;
&lt;br /&gt;
=====AngularJS=====&lt;br /&gt;
&lt;br /&gt;
Angular's templating engine simply extends HTML syntax. It uses [https://docs.angularjs.org/guide/expression binding expressions] to bind variables between controllers  and models. These binding expressions are enclosed by doubly curly braces. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li ng-repeat=&amp;quot;recipe in recipes&amp;quot; &lt;br /&gt;
     title=&amp;quot;{{recipe.title}}&amp;quot;&amp;gt; &lt;br /&gt;
    {{recipe.description}} &lt;br /&gt;
  &amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====EmberJS=====&lt;br /&gt;
&lt;br /&gt;
EmberJS uses [http://handlebarsjs.com/ Handlebars] template engine. Handlebars is an extension of [http://mustache.github.io/ Mustache] templating engine. It does not understand the [http://en.wikipedia.org/wiki/Document_Object_Model Document Object Model] structure so it is not aware of the context in which it is being used. It just does the simple string transformation. Another templating engine is being developed called [http://talks.erikbryn.com/htmlbars HTMLBars] which works on these flaws of the Handlebars. Since, HTMLBars is not yet ready therefore Handlebars is  currently being used. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   {{#each recipes}}&lt;br /&gt;
     &amp;lt;li {{bind-attr title=name}}&amp;gt;&lt;br /&gt;
        {{desc}}&lt;br /&gt;
     &amp;lt;/li&amp;gt;&lt;br /&gt;
   {{/each}}&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====BackboneJS=====&lt;br /&gt;
&lt;br /&gt;
BackboneJS doesn't have any templating engine of its own but it can be integrated with many third party templating engines. Since, [http://underscorejs.org/ Underscore] is a Backbone dependency so it is used by default for the templating purposes. But, underscore has a very basic templating engine and it has to be used in the mix with javascript. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
   &amp;lt;% _.each(recipes, function(recipe) { %&amp;gt; &lt;br /&gt;
     &amp;lt;li title=&amp;quot;&amp;lt;%- recipe.name %&amp;gt;&amp;quot;&amp;gt; &lt;br /&gt;
       &amp;lt;%- recipe.desc %&amp;gt; &lt;br /&gt;
     &amp;lt;/li&amp;gt; &lt;br /&gt;
   &amp;lt;% }); %&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference Material==&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Ruby on which Rails is based :&lt;br /&gt;
&lt;br /&gt;
#[http://rubymonk.com/ Ruby Monk]&lt;br /&gt;
#[http://rubylearning.com/ Ruby Learning]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn Rails :&lt;br /&gt;
&lt;br /&gt;
#[http://railsforzombies.org/ Rails for Zombies]&lt;br /&gt;
#[http://www.railstutorial.org/book Ruby on Rails Tutorial]&lt;br /&gt;
#[http://guides.rubyonrails.org/index.html Rails Guides]&lt;br /&gt;
&lt;br /&gt;
Following are the references to learn AngularJS :&lt;br /&gt;
&lt;br /&gt;
#[http://angularjs.org/ AngularJS] &lt;br /&gt;
#[http://www.w3schools.com/angular/ AngularJS Tutorials]&lt;br /&gt;
#[http://egghead.io/lessons AngularJS Training Videos]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rarora4</name></author>
	</entry>
</feed>