Displaying 20 results from an estimated 1000 matches similar to: "has_many :through and foo.bars.include?"
2008 May 12
3
Enumeration sum
Any idees why I can do this:
@sum = @selected.inject(0) { |sum, player| sum + player.value }
but not this:
@sum = @selected.sum { |player| player.value }
@sum = @selected.sum(&:value)
The last two give me following error:
wrong number of arguments (1 for 2)
/Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/association_collection.rb:164:in
`calculate''
2005 Dec 21
2
ActiveRecord Error with << in Collection
Hi
I get a following error:
ActiveRecord::AssociationTypeMismatch in Cmdb#create
ConfigurationItemAttributeValue expected, got Array
RAILS_ROOT: ./script/../config/..
Application Trace | Framework Trace | Full Trace
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations/association_collection.rb:128:in
`raise_on_type_mismatch''
2010 Oct 11
8
Nooby Stuck - "has_and_belongs_to_many" relationship
trying to set up a "has_and_belongs_to_many" relationship
would very much appreciate the help, not sure what im doing wrong at all.
Scheme.rb
class Scheme < ActiveRecord::Base
validates :schemename, :presence => true
belongs_to :user
has_many :levels, :dependent => :destroy
has_and_belongs_to_many :works
end
Work.rb
class Work < ActiveRecord::Base
2006 Apr 04
1
habtm and options_from_collection_for_select [1.0.0]
I ran into a problem using options_from_collection_for_select :
ActiveRecord::AssociationTypeMismatch (Topic expected, got String):
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/associations/association_collection.rb:128:in
`raise_on_type_mismatch''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
2009 Jul 08
2
RuntimeError (JPEG marker not found!):
Hi,
while generating the PDF file , i am getting following error..
please help for me.
RuntimeError (JPEG marker not found!):
C:/Ruby/lib/ruby/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/writer/
graphics/imageinfo.rb:176:in `
measure_JPEG''
C:/Ruby/lib/ruby/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/writer/
graphics/imageinfo.rb:174:in `
loop''
2006 Jul 31
1
Adding "groups" to a user model
At present I have the following models:
users <-> permissions <-> objects
I wish to expand this to include groups, so that groups can contain
users and have permissions (a user might be part of more than one
group). However, the only way I see to do this is:
users <-> user_permissions <-> objects
users <-> group_memberships <-> groups <->
2010 Jan 26
2
accepts_nested_attributes_for :has_many :through => 'bug?'
Hey guys & ladies!
I''ve got the following relationship which i''m trying to get
accepts_nested_attributes to work with. But when i submit my form, it
looks as if its expecting a Company object, rather than an array of
companies. which really doesn''t make sense considering its a
has_many :relationship.
So what i''m after, is a way to
2008 Oct 02
1
acts_as_taggable_on environment issues
Like most people, I''ve got two machines: one for development and one
for production. I''ve done everything I can to make sure the ruby/rails
environments are the same, but of course they''re not identical (I''ll
get into that in a moment). The error that I''m getting happens when I
call a method in a background task controller on the production
machine; I
2012 Oct 16
5
`method_missing_without_paginate': undefined method `class_attribute' for ActiveRecord::Base:Class
hi
i am using radiant 0.8.2 , rails 2.3.4, ruby 1.8.7 and rubygems 1.4.2. and
i can''t able to run my existing application.
error occurred :
run command for server "script/server -e production -p 3001"
error:
=> Booting WEBrick
=> Rails 2.3.4 application starting on http://0.0.0.0:3001
config.gem: Unpacked gem rack-rewrite-1.2.1 in vendor/gems has no
specification
2009 Sep 09
0
Rails 2.3.4 ActiveRecord association problem
Upgraded our app from Rails 2.2.2 to 2.3.4, and I''m now encountering
an error when adding a child to a parent.
Top of the stack:
wrong number of arguments (1 for 0)
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/
associations/has_many_association.rb:61:in `save''
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/
2006 Apr 04
2
HABTM
Hi.
Im new to Ruby and new to Ruby on Rails and have problems realizing a =20=
simple many_to_many relationship:
My tables:
items <-> items_users <-> users
------------------------------------------------------------------------=20=
--------------------------------------
id user_id =
id
name item_id name
... =
password
=
......
My Code:
class
2006 Mar 30
6
Global Method Declaration?
Is there a place where I can put a method that can be accessed in both
views and controllers?
Here''s the situation, maybe someone can suggest a better way to go about this:
I created my own custom login system with email verification and user
roles (basically, I tinkered around with SaltedHashLoginGenerator
until I finally gave up and wrote my own). One role, of course, is an
admin
2008 Nov 06
10
Rails 2.1.2 bug in include on has_many?
In my continued efforts to port my rails 1.x app to Rails 2.1.2, I keep
running into what appear to be ActiveRecord bugs.
I am using an :include on a :has_many definition:
class Request < ActiveRecord::Base
has_many :service_types, :order=>''service_types.id ASC'',
:include=>:service_response
[...]
There''s no reason this wouldn''t be supported in
2007 Oct 23
1
storeconfig DEPRECATION WARNING
Hi,
here is a warningmessage i got while i am testing my new puppet
installation with .23.2 and storedconfig and reports and all the bell
and whistle :)
DEPRECATION WARNING: Calling .create on a has_many association without
saving its owner will not work in rails 2.0, you probably want .build
instead See http://www.rubyonrails.org/deprecation for details. (called
from create at
2006 Mar 16
6
Sessions or lookups?
My application needs to know if a user is an administrator, for security
and aesthetic reasons. At the moment, I store true/false in the session
by doing the following at login:
session[:user_is_admin] = authenticated_user.is_admin?
Is this OK to do? Or should I really be doing the following every time:
User.find(session[:user_id]).is_admin?
(user_id is always in the session too)
Is there
2005 Mar 10
8
Login controller additions
I have added roles and roles_users table and updated the model so that
my users can have multiple roles.
("Admin" role does always have id = 1).
I have added these methods to my application controller.
<code>
helper_method :is_admin?
helper_method :is_user?
def is_admin?
if @session[''user'']
@session[''user''].roles.find(1)
2016 Nov 28
2
Samba on Debian 8; NT4 domain, win10
On Mon, 28 Nov 2016 09:49:31 +0100
"Stefan G. Weichinger via samba" <samba at lists.samba.org> wrote:
> Am 2016-11-26 um 20:50 schrieb Stefan G. Weichinger via samba:
>
> > Thanks for the hints, I already read the wiki, yes.
> > I will look at the users and groups next week then.
>
> attacked that now in a VM:
>
> cpied /var/lib/samba and /etc
2009 May 31
0
[HELP] pagination w habtm association and authorization plugin...
I am using the proven authorization plugin to defines roles for users,
so I can get all groups where a user is ''member''
@groups = current_user.group_memberships
I have an habtm association between groups and events
class Group < ActiveRecord::Base
has_and_belongs_to_many :events
..
class Event < ActiveRecord::Base
has_and_belongs_to_many :groups
I am trying to list
2009 May 29
1
assert method is not visible?
Hi,
test "is_admin method is not visible" do
get :is_admin
assert_???
end
is_admin is protected and should stay that way forever. What assertion
do I use?
M.
--
Posted via http://www.ruby-forum.com/.
2010 Jul 15
2
Authlogic admin user functionality
I am using authlogic as a authentication engine in my rails app.
I have two types of users 1) Users who are registered and has access
to there own profile.
2) Admin user who has access to everybody''s profile
In the user table i have a :is_admin field boolean field which defines
the admin user.
like the current_user method, Is there a way authlogic provides which
can tell me if the