Yes; goal belongs_to user. I tried what you suggested and the second line 
    config.list.columns[:user].link = false
results in an immediate error when attempting to render the form:

undefined method `link=' for nil:NilClassExtracted source (around line *#5*):2: 
3: <%= button_to "Return to Plan", plans_path, :method => :get %>
4: <div>
5:   <%= render  :active_scaffold => "members/goals", :constraints => { 
:user_id => current_user.id } %>


I created the to_label field as well.

More to the point, I don't want to list, show, or change the user AT ALL... 
I just want to leave the value that's in an existing record alone, and add 
the current_user.id to the user_id field upon create. In other words, no 
subform for Users at all. I have a before_create_save method to set the 
user_id on create.

Since I don't want any type of subform for the User, I tried turning off 
:nested and :subform in the active_scaffold initializer, but that didn't 
help.

I'll look at your other suggestions, but wanted to make sure I was clear on 
what I wanted to do.

Thanks much for your help...jon

On Monday, April 29, 2013 4:19:46 PM UTC-7, Hernán Astudillo wrote:
>
> If goal belongs_to user, and you want to list,show and maybe change the 
> user for goals but not change the user itself, steps are:
>
> - disable AS-crud calls:
>
> config.columns[:user].form_ui = :select # or :chosen, :record_select, best 
> choice depends on how many records you will have
>
> - disable links in goal list which call controller renderers
>
> conf.list.columns[:user].link = false
>
> AS by default, will try to render the user by calling .to_label method, so 
> if that's enought for you, just remember to define that method in the user 
> model
>
> def to_label
>   name
> end
>
> or if you want something more sophisticated, use helpers:
>
> GoalHelper:
> def goal_user_column(record, column)
>   "<div> #{record.name} " # add fancy stuff here
> end  
>
> or you can define specific renderers for list AND show separately
> def goal_user_show_column...
> def goal_user_list_column ...
>
>
>
>
> On Mon, Apr 29, 2013 at 4:43 PM, JESii <[email protected] <javascript:>>wrote:
>
>> Thanks; since I never expect to let the user update their information 
>> from this or similar views, I'd prefer to avoid setting up a 'dummy' 
>> controller. I just need to user_id to constrain what is displayed and 
>> update the record appropriately, leaving all the other CRUD stuff out.
>>
>> However, I'm not at all clear on how I can setup a helper (controller 
>> helper, I presume) to deal with this issue. Any suggestions on where I 
>> should start looking?
>>
>> I would think this would be a good addition to the documentation, since 
>> Devise is so prevalent in the Rails community.
>>
>> Thanks...jon
>>
>>
>> On Monday, April 29, 2013 12:44:38 PM UTC-7, Hernán Astudillo wrote:
>>
>>> it is looking for a controller for User because the other controller is 
>>> aware that there's a User associated to one column and by default it adds 
>>> all Active Scaffold stuff available for it, that includes full CRUD, 
>>> search, views, etc. For that is why it needs a controller. 
>>>
>>> You could add a basic controller for that:
>>>
>>> rails g active_scaffold_controller members::users
>>>
>>> just be careful that the route must be different from devise one
>>> You can use any name for the controller if this is an issue for you. Add 
>>> this to application_controller:
>>>
>>> def active_scaffold_controller_**for(klass)
>>> return YourControllerNameHereControll**er if klass == User
>>> end
>>>
>>> or, you can get rid of all controller things related, and just leave a 
>>> helper to render what user should look like. 
>>>
>>>
>>>
>>> On Mon, Apr 29, 2013 at 3:19 PM, JESii <[email protected]> wrote:
>>>
>>>> Thanks for the response, Herman... I tried that but still getting the 
>>>> problem. Here's my updated controller for Goals:
>>>>   active_scaffold :goal do |config|
>>>>     config.list.columns = [:statement]
>>>>     config.create.columns = [:statement]
>>>>     config.show.columns = [:statement]
>>>>     config.update.columns = [:statement]
>>>>     config.update.link.label = "Edit Goal"
>>>>     config.show.link.label = "Show Goal"
>>>>     config.create.link.label = "Add a new Goal"
>>>>   end
>>>>
>>>> I'm still getting the 'nil' error, but on a couple of occasions I got 
>>>> an error like this:
>>>>   ActionView::Template::Error (Could not find Members::UsersController 
>>>> or Members::UserController or UsersController or UserController):
>>>>
>>>> I'm using Devise, so there's no explicit Users controller.  The 
>>>> reference to 'members' is because I have a number of models/controllers 
>>>> that are all grouped under members/.
>>>>
>>>> ...jon
>>>>
>>>>
>>>> On Monday, April 29, 2013 9:03:55 AM UTC-7, Hernán Astudillo wrote:
>>>>
>>>>> your problem is your controller:
>>>>>
>>>>> config.columns = [:statement]
>>>>>
>>>>> here, you're excluding globally all columns except statement. Therefore, 
>>>>> user doesn't exist. 
>>>>>
>>>>> If you want to list only that column, use:
>>>>>
>>>>> config.list.columns = [:statement]
>>>>>
>>>>> same for show, edit, create.
>>>>>
>>>>>
>>>>>
>>>>> On Sat, Apr 27, 2013 at 6:55 PM, JESii <[email protected]> wrote:
>>>>>
>>>>>> Sorry; I was actually using AS 3.3.0.rc3 from github master...jon
>>>>>>
>>>>>>
>>>>>> On Saturday, April 27, 2013 2:03:57 PM UTC-7, JESii wrote:
>>>>>>>
>>>>>>> I have an application with ActiveScaffold (gem - 3.2.20) which has many 
>>>>>>> error symptoms: . Ruby version 1.9.3p194, Rails, 3.2.12 using the asset 
>>>>>>> pipeline. Things display OK, but Create, Edit, Show, Delete all give a 
>>>>>>> 500 internal error. It's an asset pipeline enabled, and I have the AS 
>>>>>>> css and js included in the assets setup.
>>>>>>>
>>>>>>>
>>>>>>> The details are in a pastie at http://pastie.org/7730509#1
>>>>>>>
>>>>>>>
>>>>>>> Any suggestions for what I'm doing wrong would be most appreciated.
>>>>>>>
>>>>>>>
>>>>>>> Thanks...jon
>>>>>>>
>>>>>>>  -- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>>> Groups "ActiveScaffold : Ruby on Rails Gem" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>> send an email to activescaffol...@**googlegroups.**com.
>>>>>> To post to this group, send email to actives...@googlegroups.**com.
>>>>>>
>>>>>> Visit this group at http://groups.google.com/**group**
>>>>>> /activescaffold?hl=en-US<http://groups.google.com/group/activescaffold?hl=en-US>
>>>>>> .
>>>>>> For more options, visit 
>>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
>>>>>> .
>>>>>>  
>>>>>>  
>>>>>>
>>>>>
>>>>>  -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "ActiveScaffold : Ruby on Rails Gem" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to activescaffol...@**googlegroups.com.
>>>> To post to this group, send email to actives...@googlegroups.**com.
>>>> Visit this group at http://groups.google.com/**
>>>> group/activescaffold?hl=en-US<http://groups.google.com/group/activescaffold?hl=en-US>
>>>> .
>>>> For more options, visit 
>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>> .
>>>>  
>>>>  
>>>>
>>>
>>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "ActiveScaffold : Ruby on Rails Gem" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at 
>> http://groups.google.com/group/activescaffold?hl=en-US.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/activescaffold?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to