I have a Post model and my controller looks like this:

class Admin::PostsController < Admin::AdminController
  active_scaffold :posts do |config|
    config.columns = [:title, :body, :user_id]
    config.list.columns = [:title, :body, :user_id]
  end
end

Each Post belongs to one User, each User has many Posts.  Pretty
basic.

First Question:  Using the code above, when I go to create or edit a
post, the user_id appears as an input field in the form and the poster
actually has to manually enter their user_id in order for the
association to be written to the database.  How can I do this
automatically.  I know how to remove the user_id field and label from
the form.  Do I have to do this in my model?  Like a before_create
filter or something?

Second Question:  I want to allow admins to be able to change the
user_id for each post.  This would best be accomplished by having a
drop-down select menu that is greyed out unless the user is an admin.
Again, I think I can figure out how to grey the select-box out for
admins, but I am having trouble getting the user_id to appear in a
select box in the first place.  From reading the docs, I was under the
impression that the following code might work, but it just throws up a
noMethodError (which I would be happy to post, if anyone needs to see
it):

    config.columns[:user_id].form_ui = :select
I also tried this code using "record_select" instea of just "select"

I'm a bit stuck, any help would be really great.

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en.

Reply via email to