Hi, I am using 'url_for' for constructing url in my model but it gives me error <NoMethodError: undefined method `url_for' for Xyz:Class> how to access url_for in model and it possible to call controller method in model and how to call it? Please urgently give reply?
on 2008-09-17 10:08
on 2009-02-03 00:09
Sunny Bogawat wrote: > Hi, > I am using 'url_for' for constructing url in my model but it gives me > error > <NoMethodError: undefined method `url_for' for Xyz:Class> > how to access url_for in model and it possible to call controller > method in > model and how to call it? > > > Please urgently give reply? Hi hope this code will help you, this is the code i used and it has worked for me. So, please see to it. def index redirect_to :action=> 'view', :name => 'Home' end def view @name = params[:name] @page = Page.find_by_name(@name) end def edit @name = params[:name] @page = Page.find_by_name(@name) end def save @content = params[:content] @name = params[:name] @page = Page.find_by_name(@name) if !@page @page = Page.create(:name => @name) end Revision.create(:page => @page, :content => @content) redirect_to :action => :view, :name => @name end With Regards, http://www.southcoastrecovery.com - Daniel
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.