PerfectlyNormal / tinymce-rails-imageupload

Image upload plugin for TinyMCE and Rails with the asset pipeline
MIT License
149 stars 154 forks source link

unable to upload the image #61

Closed rasool-sb closed 9 years ago

rasool-sb commented 9 years ago

Hi, Am getting error while uploading image using tinymce-rails-imageupload, the error shows in my rails server console is....

  NoMethodError (undefined method `permit' for #<ActiveSupport::HashWithIndifferentAccess:0xb2c5410>):

app/controllers/tinymce_assets_controller.rb:7:in `create'

here are the details what i have configured as:

In my model: image.rib class Image < ActiveRecord::Base has_attached_file :file belongs_to :user belongs_to :event end

In my controller: tinymce_assets_controller.rb respond_to :json

def create
  geometry = Paperclip::Geometry.from_file(params[:file])
  image    = Image.create params.permit(:file, :alt, :hint)
  render json: {
    image: {
      url:    image.file.url,
      height: geometry.height.to_i,
      width:  geometry.width.to_i
    }
  }, layout: false, content_type: "text/html"
end

In my routes.rb post '/tinymce_assets' => 'tinymce_assets#create'

In data migration: create_images.rb class CreateImages < ActiveRecord::Migration def change create_table :images do |t| t.string :alt, default: "" t.string :hint, default: "" t.attachment :file t.timestamps end end end

And my environment details are: Ubuntu 12.04, ruby 1.9.3, rails 3.2.13, tinymce-rails 4.1.5 with tinymce-rails-imageupload.. and firefox 32. please let me know if you need some more details for verification.

Please help me! suggest me! guide me! point me! :) Thanks a LOT in Advance.

PerfectlyNormal commented 9 years ago

I'm guessing you should leave out the permit-call in the controller, unless you're also using strong_parameters.

Sent from my iPhone

On 25 sep 2014, at 10:02 em, Rasool.SB notifications@github.com wrote:

Hi, Am getting error while uploading image using tinymce-rails-imageupload, the error shows in my rails server console is....

NoMethodError (undefined method permit' for #<ActiveSupport::HashWithIndifferentAccess:0xb2c5410>): app/controllers/tinymce_assets_controller.rb:7:increate'

here are the details what i have configured as:

In my model: image.rib class Image < ActiveRecord::Base has_attached_file :file belongs_to :user belongs_to :event end

In my controller: tinymce_assets_controller.rb respond_to :json

def create geometry = Paperclip::Geometry.from_file(params[:file]) image = Image.create params.permit(:file, :alt, :hint)

render json: { image: { url: image.file.url, height: geometry.height.to_i, width: geometry.width.to_i } }, layout: false, content_type: "text/html" end

In my routes.rb post '/tinymce_assets' => 'tinymce_assets#create'

In data migration: create_images.rb class CreateImages < ActiveRecord::Migration def change create_table :images do |t| t.string :alt, default: "" t.string :hint, default: "" t.attachment :file t.timestamps end end end

And my environment details are: Ubuntu 12.04, ruby 1.9.3, rails 3.2.13, tinymce-rails 4.1.5 with tinymce-rails-imageupload.. and firefox 32. please let me know if you need some more details for verification.

Please help me! suggest me! guide me! point me! :) Thanks a LOT in Advance.

\ Reply to this email directly or view it on GitHub.

rasool-sb commented 9 years ago

WooOOooW, Thanks for your very fast reply, amazed :), Yes, I tried this.., but after clicking on the insert button in "Insert picture from your computer" dialog box, the image not displays in the text_area box, it's just shoing border, I took the screenshot for verification.. pn

PerfectlyNormal commented 9 years ago

I've made a small demo app, mentioned in the readme, both the live demo and the source. You could take a look at that.

I'm guessing there's something wrong with the URL returned from the controller. Check if it works outside of an editor maybe