Skip to content

Commit

Permalink
Merge pull request #421 from lazywei/strong-parameters
Browse files Browse the repository at this point in the history
Compatibility of rails 4's strong parameters.
  • Loading branch information
jejacks0n committed Oct 21, 2013
2 parents 9b722b1 + b7edaec commit 5f17871
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/generators/mercury/install/images/images_generator.rb
Expand Up @@ -16,12 +16,13 @@ def copy_models
copy_file 'mongoid_paperclip_image.rb', 'app/models/mercury/image.rb'
else
copy_file 'ar_paperclip_image.rb', 'app/models/mercury/image.rb'
template 'ar_paperclip_image.rb.erb', 'app/models/mercury/image.rb'
migration_template 'ar_paperclip_image_migration.rb', 'db/migrate/create_mercury_images.rb'
end
end

def copy_controller
copy_file 'images_controller.rb', 'app/controllers/mercury/images_controller.rb'
template 'images_controller.rb.erb', 'app/controllers/mercury/images_controller.rb'
end

def add_routes
Expand Down
@@ -1,8 +1,9 @@
class Mercury::Image < ActiveRecord::Base

self.table_name = :mercury_images

attr_accessible :image
<% unless Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new("4.0.0") %>
attr_accessible :image
<% end %>

has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" },
:path => ":rails_root/public/system/:attachment/:id/:style/:filename",
Expand Down
Expand Up @@ -4,7 +4,11 @@ class Mercury::ImagesController < MercuryController

# POST /images.json
def create
@image = Mercury::Image.new(params[:image])
<% if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new("4.0.0") %>
@image = Mercury::Image.new(params.require(:image).permit(:image))
<% else %>
@image = Mercury::Image.new(params[:image])
<% end %>
@image.save
respond_with @image
end
Expand Down

1 comment on commit 5f17871

@waclock
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In jQuery 1.9 the method Browser was deprecated, could you please update the code so it works with 1.9 :) 👍

Please sign in to comment.