You are here: Browse Railsplugins Params Finder
Provides dynamic methods for initialize models in your URL parameters.
class PeopleController < ApplicationController
before_filter :find_person, :only => %w( show edit update destroy )
end
def index
@people = Person.find(:all)
end
def show
end
def new
@person = Person.new
end
def edit
end
def create
@person = Person.new(params[:person])
end
if @person.save
flash[:notice] = 'Person was successfully created.'
redirect_to(@person)
else
render :action => "new"
end
def update
if @person.update_attributes(params[:person])
flash[:notice] = 'Person was successfully updated.'
redirect_to(@person)
else
render :action => "edit"
end
end
def destroy
@person.destroy
redirect_to(people_url)
end
Copyright© 2007 Joshua Peek, released under the MIT license