El Tuesday 13 January 2009 07:39:55 DJ escribió:
> Hi Sergio
>              Your suggestion worked in a single shot, I was thinking
> in other way.
>              but there is one error, When i try to update users info
> along with roles(check or uncheck)
>              there is errors, the stacktrace is->
>
>              NoMethodError (undefined method `update_roles' for #<User:
> 0xb66c2724>):
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> attribute_methods.rb:260:in `method_missing'
>     /vendor/plugins/rails-authorization-plugin/lib/publishare/
> identity.rb:49:in `method_missing'
>     /vendor/plugins/rails-authorization-plugin/lib/publishare/
> identity.rb:113:in `method_missing'

The error is with rails-authorization-plugin, in a after_update or after_save 
callback. 

>     /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
> callbacks.rb:178:in `send'
>     /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
> callbacks.rb:178:in `evaluate_method'
>     /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
> callbacks.rb:166:in `call'
>     /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
> callbacks.rb:93:in `run'
>     /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
> callbacks.rb:92:in `each'
>     /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
> callbacks.rb:92:in `send'
>     /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
> callbacks.rb:92:in `run'
>     /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
> callbacks.rb:277:in `run_callbacks'
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> callbacks.rb:315:in `callback'
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> callbacks.rb:223:in `create_or_update'
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> base.rb:2400:in `save_without_validation!'
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> validations.rb:1019:in `save_without_dirty!'
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> dirty.rb:87:in `save_without_transactions!'
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> transactions.rb:150:in `save!'
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> connection_adapters/abstract/database_statements.rb:66:in
> `transaction'
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> transactions.rb:129:in `transaction'
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> transactions.rb:138:in `transaction'
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> transactions.rb:150:in `save!'
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> transactions.rb:158:in `rollback_active_record_state!'
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> transactions.rb:150:in `save!'
>     /vendor/plugins/active_scaffold/lib/active_scaffold/actions/
> update.rb:82:in `do_update'
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> connection_adapters/abstract/database_statements.rb:66:in
> `transaction'
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> transactions.rb:129:in `transaction'
>     /vendor/plugins/active_scaffold/lib/active_scaffold/actions/
> update.rb:77:in `do_update'
>     /vendor/plugins/active_scaffold/lib/active_scaffold/actions/
> update.rb:28:in `update'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> base.rb:1253:in `send'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> base.rb:1253:in `perform_action_without_filters'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> filters.rb:617:in `call_filters'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> filters.rb:610:in `perform_action_without_benchmark'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> benchmarking.rb:68:in `perform_action_without_rescue'
>     /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> benchmarking.rb:68:in `perform_action_without_rescue'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> rescue.rb:136:in `perform_action_without_caching'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> caching/sql_cache.rb:13:in `perform_action'
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> connection_adapters/abstract/query_cache.rb:34:in `cache'
>     /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
> query_cache.rb:8:in `cache'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> caching/sql_cache.rb:12:in `perform_action'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> base.rb:524:in `send'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> base.rb:524:in `process_without_filters'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> filters.rb:606:in `process_without_session_management_support'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> session_management.rb:134:in `process'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> base.rb:392:in `process'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> dispatcher.rb:183:in `handle_request'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> dispatcher.rb:110:in `dispatch_unlocked'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> dispatcher.rb:123:in `dispatch'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> dispatcher.rb:122:in `synchronize'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> dispatcher.rb:122:in `dispatch'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> dispatcher.rb:132:in `dispatch_cgi'
>     /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> dispatcher.rb:39:in `dispatch'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/
> rails.rb:76:in `process'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/
> rails.rb:74:in `synchronize'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/
> rails.rb:74:in `process'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in
> `process_client'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in
> `each'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in
> `process_client'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in
> `run'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in
> `initialize'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in
> `new'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in
> `run'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in
> `initialize'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in
> `new'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in
> `run'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/
> configurator.rb:282:in `run'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/
> configurator.rb:281:in `each'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/
> configurator.rb:281:in `run'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in
> `run'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:
> 212:in `run'
>     /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
>     /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
> dependencies.rb:142:in `load_without_new_constant_marking'
>     /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
> dependencies.rb:142:in `load'
>     /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
> dependencies.rb:521:in `new_constants_in'
>     /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
> dependencies.rb:142:in `load'
>     /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/servers/
> mongrel.rb:64
>     /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> `gem_original_require'
>     /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> `require'
>     /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
> dependencies.rb:153:in `require'
>     /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
> dependencies.rb:521:in `new_constants_in'
>     /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
> dependencies.rb:153:in `require'
>     /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/server.rb:49
>     /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> `gem_original_require'
>     /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> `require'
>     script/server:3
>
> Thanks again
> Dwija
>
> On Jan 12, 6:17 pm, "Sergio Cambra .:: entreCables - Symbol Servicios
>
> Informáticos S.L. ::." <[email protected]> wrote:
> > El Monday 12 January 2009 12:34:51 DJ escribió:
> > > Hi
> > >     Sergio
> > >               I could not understand why i need a select box for roles
> > > in roles controller? I simply need check boxes for roles in user's
> > > creation or updation . Also abt the roles, i have separate model by
> > > which i can create , update and delete roles.
> > > Now as user and roles maintains HABTM relationship so i should be able
> > > to fetch roles for each user for both create and update operation.
> >
> > In your users controller you should have a roles column and you have to
> > set select form_ui for it.
> >
> > class User < ActiveRecord::Base
> >   has_and_belongs_to_many :roles
> > end
> >
> > class Role < ActiveRecord::Base
> >   has_and_belongs_to_many :users
> > end
> >
> > class UsersControllers < ApplicationController
> >   active_scaffold do |config|
> >     config.columns[:roles].form_ui = :select
> >   end
> > end
> >
> > > And i indeed done one select interface in one of my controller like->
> > >
> > > module EmployeesHelper
> > >  def user_column(record)
> > >     if record.user.nil?
> > >       ""
> > >     else
> > >       record.user.id
> > >     end
> > >  end
> > >
> > >   def user_form_column(record,input_name)
> > >     options = User.find(:all).collect do |c|
> > >       [ c.email, c.id ]
> > >     end
> > >     select :record, :user_id, options, {:include_blank =>
> > > false, :prefix => input_name},
> > >                                       {:name => input_name + '[id]'}
> > >   end
> > >
> > > end
> > >
> > > and then config.columns[:user].form_ui = :select  in userscontroller.
> >
> > You don't need those helpers to use a select form_ui, it's builtin in
> > active scaffold, you only have to set form_ui to association column. Try
> > setting form_ui and removing user_form_column.
> >
> > If you add a to_label method to user, it will be used to show users in
> > select and in list, so you can remove user_column helper too.
> >
> > > I do hope , i am not missing anything
> > > Dwija
> > >
> > > On Jan 12, 3:27 pm, "Sergio Cambra .:: entreCables - Symbol Servicios
> > >
> > > Informáticos S.L. ::." <[email protected]> wrote:
> > > > El Monday 12 January 2009 11:19:22 DJ escribió:
> > > > > Hi
> > > > >     Groups
> > > > >                 I am trying to show a group of check boxes along
> > > > > with their boolean values for a HABTM relationship say
> > > > >
> > > > >  has_and_belongs_to_many :roles
> > > > >  has_and_belongs_to_many :users
> > > > >
> > > > > so the roles table are ->
> > > > >   id                     name                     type
> > > > >    1                     create                    ..
> > > > >    2                      read                      ..
> > > > >    3                     update                   ..
> > > > >
> > > > > users tables->
> > > > >    id         name            email
> > > > >    1          admin             ...
> > > > >    2          harry               ...
> > > > >
> > > > > roles_user table->
> > > > >
> > > > >   role_id  user_id
> > > > >     1              1
> > > > >     1              2
> > > > >     2              2
> > > > >
> > > > > What i am trying is to show the check boxes for every role name
> > > > > along with their boolean values(checked or not)  in each users
> > > > > update form. I have tried with name_form_column in user helper
> > > > > function but could not get the desired result. Are their any better
> > > > > way?
> > > >
> > > > Have you tried to set :select to form_ui?
> > > > config.columns[:roles].form_ui = :select
> > > >
> > > > --
> > > > Sergio Cambra .:: entreCables - Symbol Servicios Informáticos S.L.
> > > > ::. Nicolás Guillén 6, locales 2 y 3. 50.018 Zaragoza
> > > > T) 902 021 404 F) 976 52 98 07 E) [email protected]
> >
> > --
> > Sergio Cambra .:: entreCables - Symbol Servicios Informáticos S.L. ::.
> > Nicolás Guillén 6, locales 2 y 3. 50.018 Zaragoza
> > T) 902 021 404 F) 976 52 98 07 E) [email protected]
>
> 


-- 
Sergio Cambra .:: entreCables - Symbol Servicios Informáticos S.L. ::.
Nicolás Guillén 6, locales 2 y 3. 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

  • HA... DJ
    • ... Sergio Cambra .:: entreCables - Symbol Servicios Informáticos S.L. ::.
      • ... DJ
        • ... Sergio Cambra .:: entreCables - Symbol Servicios Informáticos S.L. ::.
          • ... DJ
            • ... Sergio Cambra .:: entreCables - Symbol Servicios Informáticos S.L. ::.
          • ... naaano

Reply via email to