Hi
Is there a way to use
map.resources
in routes for a controller, but without including the create or new
actions?
Cheers
Hi
Is there a way to use
map.resources
in routes for a controller, but without including the create or new
actions?
Cheers
Daniel ----- wrote:
Hi
Is there a way to use
map.resources
in routes for a controller, but without including the create or new
actions?Cheers
If the controller does not define the methods they will not exist, but
by default, rails throws and ugly error message. (well no uglier then if
you had misspelled a URL but…) You might instead what to create these
methods and simply have them throw a pretty 404 or maybe 401(<- Some
REST guru will be able to tell you which code to throw)
John
Hey Daniel,
As far as I understand it, all you have to do is not define the create
and new action in your controller.
If those actions are not defined in the controller AND there are no
“new.rhtml” and “create.rhtml” in the views folder, I think it will
behave like you want to.
HTH
~Rohith
Couldn’t you just use a before_filter to redirect to ether a nice
clean error page or even just use the index action instead?
before_filter :show_error, :only => [:new, :create]
def show_error
redirect_to plural_path()
end
On 4/26/07, Robert W. [email protected] wrote:
Couldn’t you just use a before_filter to redirect to ether a nice
clean error page or even just use the index action instead?before_filter :show_error, :only => [:new, :create]
def show_error
redirect_to plural_path()
end
Really what I was thinking was to not define routes for non-existant
actions. But if I can’t turn some of them off then something like
redirection or a nice error will be sufficient.
Cheers
On 4/25/07, John M. [email protected] wrote:
Cheers
If the controller does not define the methods they will not exist, but
by default, rails throws and ugly error message. (well no uglier then if
you had misspelled a URL but…) You might instead what to create these
methods and simply have them throw a pretty 404 or maybe 401(<- Some
REST guru will be able to tell you which code to throw)John
–
I guess it is the nasty Error page that I’m looking to avoid. Thanx for
the
idea.
Cheers
Daniel
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs