Ruby
on Rails 4
The Biggest
change see in Rails 4 is the no longer support Ruby 1.8. It
should be run in top of Ruby 1.9. Specifically 1.9.3 version. It has
many features compared with previous releases. So we should install
it.
There is many
features and changes in Rails 4. We just follow some most important
features in Rails 4 here.
So let me give
the agenda. First we will check controllers and views.
Controllers
and Views:
All the changes
in Action controller and Actionpack.
- HTML5 helpers
- Collection form helpers
- Flash types
- before_action
- Caching
The next chapters
are all about the new features.
- Live streaming
- Turbolinks
- Dynamic index.html
- Strong parameters
The next chapter
will cover the Active record and the major differences and features
of the Module.
Rails interacts
with postgresql database with hstore and array storage
capability.ActiveModel::Model its new to Rails4. Active Record’s
not method new to Rails4 and also concerns.
And also concerns
in Router. Also we will taking a look at the PATCH verb.Its an HTTP
verb already exists long time ago those never considers in Rails and
this time it is.
Finally we can
take a look about upgrade notes. We can consider the application as
plugin folder, Now would have consider gems as plugins. Extractions
of two major functionality of Rails 1. Active Resourse and 2.
Observers.
HTML5
Form Helpers:
First one is
week_field. Code looks like below.It asks to select the particular
week of the year.
<%=
week_field_tag :week%>
Similarly to date
field , datetime field, datetime local field.
<%=
date_field_tag :date%>
<%=
datetime_field_tag :datetime%>
<%=
datetime_local_field_tag :datetime%>
Likewise, there
are month field, time field, color and highlight fields are there.
<%=
time_field_tag :time%>
<%=
month_field_tag :month%>
<%=
color_field_tag :color%>
<%= highlight
“test one two three”, “one” %>
Highlight element
is not an input method and it used to new HTML5 tag called <mark>
</mark>
Collection
Form Helpers:
List out and selecting the item in form using
collection select which available Rails3. Based on belongs_to
relationship you can determine the makes the select box and then you
select the value and key for each of the options. This features
already exist in Rails 3. And other two more helpers available to do
something like this.
collection_radio_buttons: