Url_for not working

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?

Sunny B. 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