Logo F2FInterview

Ruby Rails Interview Questions

Q   |   QA

With Rails 2.0, you may have noticed that dynamic scaffolding breaks–that is, if you have a controller with scaffold :model_name in it, all the scaffolded actions–new, delete, index–no longer exist! In Rails 2.0, you can only generate static scaffolding–that is, you can use the scaffold to generate the files for controllers, models, and views.

What’s more, Rails 2.0 allows you to specify the model attributes inside the scaffold. This then creates views with all the appropriate fields, and it also creates the migration with all the fields in it! Excellent!

As an example, say we wanted to create a blog-post model. We could generate it like so:

script/generate scaffold Post title:string content:text
category_id:integer

You’ll notice Rails will generate, among other things:

► A post.rb model file
► A posts_controller.rb controller file
► A posts view folder containing views for the index, show, new, and edit actions
► A DB migration called xxx_create_posts
► A unit-test, fixtures file, and helper

Everything you need–indeed, everything the dynamic scaffolding provided–is included, albeit as static content. All you need to do is migrate your DB and you’re up and flying!

So the main difference is, with dynamic scaffolding you can generate new, edit and delete methods but with static scaffolding you can't 

Rails makes extensive use of symbols. A symbol looks like a variable symbols name, but it’s prefixed with a colon. Examples of symbols include :action,:line_items, and :id.

Rails uses symbols to identify things. In particular, it uses them as keys when naming method parameters and looking things up in hashes. For example: redirect_to :action => "edit", :id => params[:id] 

Session is used for maintaining the particular value throughout the session..(browser closed)

e.x: session[:value]="poornimad"

this values is not changed until the browser closed..

Cookies:
*********
This is used to store the values in the Browser..this  value is not delete till the cookies are deleted..This  cookies concept is same as java cookies. The concept is same. 

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: