Not compatible as mountable engine #286

jseitel opened this Issue Sep 13, 2012 · 3 comments


None yet

3 participants

jseitel commented Sep 13, 2012

I'm loosely using this guide to graft Refinery onto my existing Rails app:

However, when I tried to create a new blog post, I would get errors. I dug into the source and I think this line (in /app/models/refinery/blog/post.rb) is the culprit:

belongs_to :author, :class_name => 'Refinery::User', :foreign_key => :user_id, :readonly => true

See, I'm using my existing User model, whereas this gem is assuming I'm using Refinery's User model. For the short-term, I hacked around this by changing :class_name to be simply 'User'.

I think the general solution would be something like this:

  1. Add a config setting (maybe config.user_model?) that contains the Rails model you want to use for the blog
  2. If unspecified, default to Refinery::User

Any thoughts? I'd be happy to write a patch for the behavior above.

parndt commented Sep 13, 2012

Sure, especially if you are happy to patch it :)

I think it should be config.user_class

@jseitel jseitel added a commit to jseitel/refinerycms-blog that referenced this issue Sep 21, 2012
@jseitel jseitel Adding support for Refinery::Blog.user_class. This will enable the Re…
…finery::Blog engine to work out-of-box with existing Rails applications.

This issue was tracked in #286.

Thank @jseitel you're a life saver. One extra thing though to anyone still having a little trouble

make sure you add something like

alias_attribute :username, :name

if your User Model doesn't have a :username attribute

parndt commented Nov 29, 2012

Closing this as there are open pull requests related to it. Thanks!

@parndt parndt closed this Nov 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment