Closed benoitr closed 10 years ago
I solved this by not relying on including the ActiveRecord
ORM.
Instead of having this
class RedactorRails::Asset < ActiveRecord::Base
include RedactorRails::Orm::ActiveRecord::AssetBase
delegate :url, :current_path, :size, :content_type, :filename, :to => :data
validates_presence_of :data
end
I have this
require 'redactor-rails/orm/base'
class RedactorRails::Asset < ActiveRecord::Base
include RedactorRails::Orm::Base::AssetBase::InstanceMethods
self.table_name = 'redactor_assets'
belongs_to :assetable, :polymorphic => true
attr_accessible :data, :assetable_type, :assetable_id, :assetable
delegate :url, :current_path, :size, :content_type, :filename, :to => :data
validates_presence_of :data
end
The above doesn't work. The only way I got it to work without authentication was to go back to an older version
gem 'redactor-rails', '0.3.3'
Then just make sure you take the user_id column out of the migration (or make a new migration remove the user_id column if it's already in the DB), and you're good to go.
KevinSjoberg's workaround works in Rails 4 if you delete the attr_accessible line.
In the documentation, it seems that we could use redactor-rails without the devise option.
However, it seems that user_id is needed. Otherwise, it raises an error due to redactor_authenticate_user! (before_filter)
I've succeeded to implement this like so:
config/redactor.rb
app/controllers/application_controller.rb
Is there is a better way to implement this or is there a bug when not passing the devise option ? Thanks