REST show action :- using other field data

show action use primary key “id” for displaying a particular record.

if want to use other filed data as the link /welcomes/john
( where welcomes is the controller and john is the value in the name field )

In the controller the tweak is:- instead of @welcome = Welcome.find(params[:id])

def show

@welcome=Welcome.where(“name = ? “, params[:id]).first
if @welcome.nil?
@welcome = Welcome.find(params[:id])

This entry was posted in rails, ROR, ruby on rails, web development and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s