I am not sure if I am going about this the right way or not.
I have a model Neighborhood. I have a two ways you can add a neighborhood, one as a logged in user and the other as a public person. The forms vary a bit. So I made another view with a custom action. The problem is this action is adding a new record and there开发者_JS百科fore calls on "create." When it calls the create action it looks to redirect to a path that cannot exist on the public form.
Either I am doing this completely wrong or there is a way to tell my custom action to save the Neighborhood record so I can redirect on the public side.
In the create
action, conditionally redirect to either the public / private page depending on the user's status:
def create
# create code goes here
if current_user?
redirect_to neighborhoods_path
else
redirect_to root_path
end
end
Or is there something that I am not understanding from your question?
i think you are saving both (public and registered users), the Neighborhood details are added to the same details. you might different this by having a user id or something
if so, As i see you can use the same controller and action. All you have to do is
identify the user like is_registred? (provided that you have a method to identify if a use is logged or not) and according to the user load layout only
Ex:
pseudo code would be
if is_registred?
render public layout
else
render registerd user layout
and you might have to check authorizations as well. Hope I understood your question
cheers
sameera
精彩评论