Created
July 14, 2010 21:14
-
-
Save tomfast/476080 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def new | |
@accessory = Accessory.new({ :client_id => params[:client_id] }) | |
# b/c an accessory can be nested under client or lifting_device | |
@parent = find_parent | |
@users = (User.client_users @client.id).client_user_roles | |
end | |
def create | |
@parent = find_parent | |
@accessory = @parent.accessories.build(params[:accessory]) | |
if @accessory.save | |
flash[:notice] = "Accessory created successfully." | |
if @parent.is_a? Client | |
redirect_to client_accessory_path(@parent, @accessory) | |
else | |
redirect_to lifting_device_accessory_path(@parent, @accessory) | |
end | |
else | |
@users = (User.client_users @client.id).client_user_roles | |
render 'new' | |
end | |
end | |
def show | |
@parent = find_parent | |
@accessory = @parent.accessories.find(params[:id]) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please see line#6, line#20.
We need to make sure the proper vars are set for the form if update / create attempt was not valid.
I'm wondering if this data should be retrieved in the view instead of the controller? I'm not a fan of the duplication of code right now.
Thoughts?