Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use redactor-rails without devise #85

Closed
benoitr opened this issue Aug 30, 2013 · 3 comments
Closed

Use redactor-rails without devise #85

benoitr opened this issue Aug 30, 2013 · 3 comments

Comments

@benoitr
Copy link

benoitr commented Aug 30, 2013

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

# Overrides the user class

module RedactorRails
  def self.devise_user
  end
end

app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
 ...

  def redactor_authenticate_user!
  end

  def redactor_current_user
  end
end

Is there is a better way to implement this or is there a bug when not passing the devise option ? Thanks

@hovsater
Copy link

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

@Arcolye
Copy link

Arcolye commented May 2, 2014

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.

@Arcolye
Copy link

Arcolye commented May 7, 2014

KevinSjoberg's workaround works in Rails 4 if you delete the attr_accessible line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants