Skip to content
Browse files

change orm_instance's update_attributes call to update for Rails 4

  • Loading branch information...
1 parent bd0da37 commit 011d0f8e00746c8044bcf5e1028bc385d9709e5f @rsl rsl committed Jun 20, 2013
View
8 lib/generators/rails/responders_controller_generator.rb
@@ -14,6 +14,14 @@ def flash?
Rails.application.config.responders.flash_keys.blank?
end
end
+
+ def orm_instance_update(params)
+ if orm_instance.respond_to?(:update)
+ orm_instance.update params
+ else
+ orm_instance.update_attributes params
+ end
+ end
end
end
end
View
2 lib/generators/rails/templates/controller.rb
@@ -29,7 +29,7 @@ def create
def update
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
- <%= "flash[:notice] = '#{class_name} was successfully updated.' if " if flash? %>@<%= orm_instance.update_attributes("params[:#{file_name}]") %>
+ <%= "flash[:notice] = '#{class_name} was successfully updated.' if " if flash? %>@<%= orm_instance_update("params[:#{file_name}]") %>
respond_with(@<%= file_name %>)
end

0 comments on commit 011d0f8

Please sign in to comment.
Something went wrong with that request. Please try again.