Displaying 20 results from an estimated 29 matches for "have_many".
Did you mean:
has_many
2007 May 05
4
autogenerated it (was ''Custom Matcher and NAME NOT GENERATED annoyance'')
> On 5/5/07, Luis Lavena <luislavena at gmail.com> wrote:
> > describe "A User (in general)" do
> > before(:each) do
> > @user = User.new
> > end
> >
> > it { @user.should have_many(:contest_public_votes) }
> > it { @user.should have_many(:design_industry_user_interests) }
> > it { @user.should have_one(:user_extension) }
> > end
> >
When I''ve used the autogenerated names, I''ve used specify:
specify { @user.should have_many(:cont...
2011 Sep 14
1
rspec and should have_many through
Hi,
Anyone can help me with rspec shoulda validations please.
I can''t get the syntax right for these validations. Please correct me
it { should have_one :tradable, :through => :trade_order}
it { should belong_to :source, :polymorphic => true }
it { should have_many :transfers, :as => :source }
this is for Rspec 2, rails 3.1,
gem "rspec-rails"
gem "remarkable_activerecord", "~> 4.0.0.alpha4"
gem ''rspec-rails-ext''
gem ''rspec-rails-matchers''
gem "shoulda-matchers"
2009 Jun 27
6
User has many topics or subtopics
Hi,
So i have users in the system and i have topics. Topics also
have_many subtopics. What is the cleanest way to setup the AR
relationships if a user can either have_many topics or subtopics ?
Its basically a dual select box dropdown, where the second dropdown is
optional.
Is the best to have user_topics, and user_subtopics tables and manage
that way ? or combine int...
2011 Mar 01
11
Did rails or shoulda go insane on the inflection of 'taxes'?
...tates'' has many :xp_jurisdiction_taxes.
In my spec I am using a shoulda helper to test the association but get the
following error. BTW, greped the whole project just in case and the string
''taxi'' exists nowhere.
1) XpJurisdictionStates
Failure/Error: it { should have_many(:xp_jurisdiction_taxes) }
NameError:
uninitialized constant XpJurisdictionStates::XpJurisdictionTaxis
# ./spec/models/xp_jurisdiction_states_spec.rb:4:in `block (2 levels)
in <top (required)>''
Not sure if this is a rails or shoulda issue (I am starting to think it i...
2007 Oct 19
11
Patch idea for rspec_on_rails
I recently wrote a matcher for testing AR associations which allows
you to specify things like:
Foo.should have_many(:bars).through(:bazes)
I''m pretty darned proud of it and a couple of people have suggested
that I should submit it to the rspec_on_rails project. Before I go to
the trouble of writing out rdoc and fully spec''ing it, I just wanted
to make sure this was something the community woul...
2007 Mar 29
21
a better "should have valid associations"
This is pretty much the same as last time around, if you recall.
Thanks to Wilson for converting to the new form. I''ve added a few
lines. Basically, it iterates over your model associations and does
two things.
- First, just try to call the association. Usually fixes speeling
erors or other such silliness.
- Second, try to find a record with an :include on the association.
This
2007 May 04
2
Custom Matcher and NAME NOT GENERATED annoyance
...rying to take advantage of it.
Since I often prior code/define all the "examples", I have created a
few matchers to fulfill associations and validations of attributes.
Example:
describe "A User (in general)" do
before(:each) do
@user = User.new
end
it { @user.should have_many(:contest_public_votes) }
it { @user.should have_many(:design_industry_user_interests) }
it { @user.should have_one(:user_extension) }
end
That creates the following descriptions:
A User (in general)
- should has_many contest_public_votes
- should has_many design_industry_user_interests
- shou...
2011 Jun 30
8
Error of DEPRECATION WARNING
Hi,
I Have a strange error when i type the command "rake db:migrate "
Can you help to solve this error or give me some advices
the error is:
DEPRECATION WARNING: Rake tasks in /home/joanne/Desktop/picto/vendor/
plugins/prawnto/tasks/prawnto_tasks.rake are deprecated. Use lib/tasks
instead. (called from <top (required)> at /home/joanne/Desktop/picto/
Rakefile:7)
thanks for help
2012 May 04
3
Database schema question
...migrations & associations.
Basically, my app is an occasion reminder service that emails users when
occasions that they select or input are coming up.
Occasions will be selected from a checkbox type list or alternatively
manually input by the user (name and date of the occasion).
Users can have_many occassions.
How would i set this up in my models? So far i have:
class Reminder < ActiveRecord::Base
attr_accessible :date, :name
belongs_to :user
end
class User < ActiveRecord::Base
attr_accessible :address, :birthday, :city, :email, :gender, :interests,
:name, :postal_code
has_...
2011 Jul 11
36
has_many and belongs_to association
Hi ,
I want to test the one below but I got the problem
belongs_to :name, :class_name => "Phrase", :foreign_key => "name"
in my test
context "test"do
should have_many :phrases
end
in language.rb
belongs_to :name, :class_name => "Phrase", :foreign_key => "name"
error is
1) Failure:
test: check has_many and belongs_to association should have many
languages. (PhraseTest) [/usr/local/lib/ruby/gems/1.9.1/gems/
shoulda-2.11.3/lib/sho...
2007 Aug 10
0
ActiveRecordAssociationMatcher
...ciate any comments.
It lets you spec your associations like this:
describe Record do
include ActiveRecordAssociationMatchers
it "should belong to artist and use a counter cache" do
Record.should belong_to(:artist).with_options(:counter_cache => true)
end
it "should have_many tracks" do
Record.should
have_many(:tracks).with_class_name("Song).and_options(:include =>
:writers)
end
end
Please see my blog entry or the pastie for more details.
http://stevetooke.karmatrading.co.uk/2007/8/10/simple-rails-association-matching-with-rspec
http://pastie.caboo....
2011 Sep 05
0
undefined method `dependent' - rspec and shoulda
hello,
Getting this error when using shoulda and rspec for model tests.
my gemfile
...
gem "shoulda-matchers"
..
spec file
..
it { should have_many(:balances).dependent(:destroy) }
error:
User shoulda validations
Failure/Error: it { should
have_many(:balances).dependent(:destroy) }
NoMethodError:
undefined method `dependent'' for #<RSpec::Matchers::Matcher:
0xb2d4294>
2006 Mar 24
7
Polymorphic associations?
I''ve read the stuff about polymorphic associations here:
http://wiki.rubyonrails.org/rails/pages/UnderstandingPolymorphicAssociations
But I''m not sure what exactly they are and what their advantage is. Are
they the same as HABTM, but they''re "two-way"?
Joe
--
Posted via http://www.ruby-forum.com/.
2006 Mar 21
2
Sorting by computed temporary field
Hey all,
I''m rather new to Ruby and Rails (and not great with SQL), but I''m
developing a ride sharing app and would like to be able to sort on
something I don''t have stored.
I have users, events, and rides, each of which has a zip code. Events
have_many rides, and rides belong_to events.
When an event is selected, I''d like to be able to show a list of rides
to that event, sorted by distance from the logged-in user.
What are some ways to do that? Here''s what I can think of:
- Make a new find_and_sort method that adds a new @di...
2008 Jan 10
21
Shoulda
Hey, we''re currently using shoulda (http://dev.thoughtbot.com/
shoulda/) on a project and I saw some things that would be really nice
to see in rspec, namely the should_ methods, and especially the
should_be_restful method. Do these go against the rspec goals at
all? Or could an ambitious programmer go to town implementing these
for rspec_on_rails?
Nathan Sutton
fowlduck at
2006 Mar 22
10
Need for multiple acts_as_list
I have a model "Childmodel" that belongs_to two other models "Parent1"
and "Parent2". "Parent1" "has_many :childmodels, :order => :positionp1"
and "Parent2" "has_many :childmodels, :order => :positionp2". i.e. The
child is independently positioned within each of its parents.
This works fine and gets me the useful
2008 Mar 12
2
nested routes with a 2-way has_many using join table?
I have two classes, InstructionalObject and Assets. They both have_many
of the other, implemented through a join table (so it''s like a habtm
without the habtm).
For the next version of our app, we''re refactoring to RESTful, and i''m
having trouble with my nested resources/routes. I tried this, in
routes.rb:
map.resources :assets do |asse...
2009 May 24
6
belongs_to not saving foreign key
Under Rails 2.3.2 using a completely brand new project, I have 2
models:
class Author < ActiveRecord::Base
# name:string
end
class Book < ActiveRecord::Base
# title:string
belongs_to :author # author_id
end
And a simple test where i create a Book with an Author using the
belongs_to and then update the foreign key directly:
require ''test_helper''
class BookTest
2012 Jan 27
3
How to test the model dependence ?
Good morning,
I''m new to rails and am having some basic questions in development. See
if anyone can help me with a test problem. I need to test if my model
"Procedure" is linked to the workflow. If not, the system must
acknowledge an error. Below is the code that is in the file test \ unit
\ procedure_test.rb.
require ''test_helper''
class ProcedureTest <
2006 Feb 14
10
acts_as_versioned and getting authors
Hey guys and gals,
I have the following object that has acts_as_versioned:
class Note < ActiveRecord::Base
acts_as_versioned
belongs_to :user
end
The schema for my notes table is as follows:
create_table :notes, :force => true do |t|
t.column :id, :integer
t.column :noteshare_id, :integer
t.column :user_id, :integer
t.column :title, :string