Ruby on Rails 5.0 for Autodidacts: Learn Ruby 2.3 and Rails 5.0
Rate it:
Open Preview
Kindle Notes & Highlights
8%
Flag icon
else   puts 'a is not 10' end
8%
Flag icon
if a == 10   puts 'a is 10' elsif a == 20   puts 'a is 20' end
9%
Flag icon
Arrays An array is a list of objects. Let’s play around in irb: $ irb >> a = [1,2,3,4,5]
14%
Flag icon
One of the cardinal sins in the MVC model is to put too much program logic into the view.
14%
Flag icon
if I have a value in the controller that I want to display in the view, then I need a mechanism for this. This is referred to as instance variable and always starts with a @.
15%
Flag icon
Even with small web projects, there are often elements that appear repeatedly, for example a footer on the page with contact info or a menu. Rails gives us the option of encapsulate this HTML code in form of partials and then integrating it within a view. A partial is also stored in the directory app/views/example/. But the file name must start with an underscore (_).
15%
Flag icon
<%= render "footer" %>
16%
Flag icon
One of my best buddies when developing Rails applications is the Tab key. Whenever you are looking for a method for a particular problem, recreate it in the Rails console and then press the Tab key twice to list all available methods. The names of the
16%
Flag icon
You can use the command rails generate to display a list of available generators: $ rails
16%
Flag icon
number from 1 to 5, you can define the following helper in the file app/helpers/application_helper.rb : Listing 15. app/helpers/application_helper.rb module ApplicationHelper   def render_stars(value)     output = ''
17%
Flag icon
ApplicationController   def index     @foo = 'bar'   end end And