Displaying 20 results from an estimated 20000 matches similar to: "question about records count."
2010 Mar 10
2
"must be nil" validation?
Hey guys, is there a validation that essentially acts the opposite way
of "validates_presence_of". That is, the attribute in question must be
nil, or blank, non-existent. If not, what''s the best way to prevent a
user from altering a web form attempting to submit data to a field
that they should never have access to?
Thanks!
--
You received this message because you are
2012 Sep 12
2
how to generate third table in test database
hi all,
has_and_belongs_to_many :cows
has_and_belongs_to_many :milkmans
i am using has_and_belongs_to_many in my app.I know this will create
third table internally cows_milkmans in mysql database.
when i migrate develpoment database i have table cows_milkmans. Good no
Problem till now.
Now a problem start When i migrate test database there is no
such cows_milkmans table is present..
2010 Oct 03
7
Rails 3, Validates, Custom Message
In Rails < 3, I could have a validation on model such as:
validates_presence_of :name, :message => "some custom message here"
If I try something similar in Rails 3:
validates :name, :presence => true , :message => "some other custom
message"
obviously, it throws an exception. So the question is, in Rails 3, how
to you give a simple custom message? Do I need to
2010 Jan 27
4
Better way to count Active Record Data?
I am trying to get hourly counts of orders between different price
ranges from my database. I''m thinking there has got to be a better way
than looping through each record and checking if the created_at time
fits between hour 1, 2, 3, 4, etc of the day and then returning the
count.
Currently I am displaying just a total of the days sales that are
between different dollar amounts this
2010 Apr 21
3
Anyone else notice that http://api.rubyonrails.org has been hijacked?
???
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
2012 Jan 30
4
Reaching into a has_and_belongs_to_many - will :through work?
Hi. I''m hoping somebody can tell me that I''ve just gotten my syntax
wrong and I can in fact do what I want to do.
I''ve got a Group, and a Group has_many Campaigns.
Campaign has_and_belongs_to_many Users (and, naturally, vice versa).
So I''ve got a groups table, a campaigns table (that has a group_id), a
campaigns_users join table (with campaign_id and
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
2012 Feb 14
4
What I'm doing wrong, has_and_belong_to_many
Hello, I''m trying to insert into my migrate but when I try on rails
console this error shows:
1.9.3-p0 :001 > group = Group.new
=> #<Group id: nil, name: nil, description: nil, created_at: nil,
updated_at: nil>
1.9.3-p0 :002 > group.name = "Group Name"
=> "Group Name"
1.9.3-p0 :003 > group.description = "Description"
=>
2012 Sep 04
5
Associations and Math between Models
I''ve setup two models, 1 and 2, that are associated by
has_and_belongs_to_many. I''m trying to get an attribute from model_1 to use
in a method in model_2. When I use the code below, I get an error saying
''undefined method model_1_id''. What am I missing? Thanks!
Model_2.rb
Class Model_2 < ActiveRecord::Base
...
has_and_belongs_to_many :model_1
def
2011 Oct 23
7
taking oDesk test
Hi! Maybe, you know thing such as odesk tests. Here will be place we
discuss about some questions of them. I can''t understand what they want.
(Rails 3)
1.Screenshot-3.png. What is answer? I think d, but I can''t find
Net::HTTP.open function in API.
2. Screenshot-5.png. I can''t understand what they want from me. I work
only with RSpec
3. Screenshot-6.png. I start to
2010 Aug 18
6
Once I added this HABTM, one of my 'through' relationships, on a non-habtm model, seems to have broke?
I''m a rails newb and have been Googling about this, but I''m still stumped.
Not showing everything here, but basically it should be a pretty common
setup so I''m sure others know what I''m doing wrong.
- A meter can belong to many meter_groups
- A meter_group can have many meters.
- A user can ''subscribe'' to viewing a meter_group (Subscription)
2011 Feb 23
3
validates, what's wrong?
class Category < ActiveRecord::Base
belongs_to :sector
has_and_belongs_to_many :suppliers
validates :sector, :name, :presence => true
As you see I have validates :sector, :presence => true.
When I create a new Category, if I don''t select a sector I have an
error page with the message:
Couldn''t find Sector with ID=
But there is the validates, why I don''t
2009 Dec 13
4
any use of flash causing "stack level too deep"
Is there any way to clear what''s in there?
This happens any time flash[] is in my code. It can be setting or
reading a value.
I''ve tried commenting out all uses of flash in my code to get a few
different pages to load, thinking this would clear the values, but no
luck.
If I get into the debugger, a p flash or pp flash will give a ''Stack
level too deep'' error
2006 Feb 28
8
HABTM count table
Hello,
I have a question about HABTM and counting records.
I have these models
class Sort < ActiveRecord::Base
has_and_belongs_to_many :reports
end
class Report < ActiveRecord::Base
has_and_belongs_to_many :region
has_and_belongs_to_many :subjects
has_and_belongs_to_many :sorts
end
And i would like to get a count like
@sort.reports.count
The problem is get this query:
2010 Jul 04
1
Rails 3: ActiveRecord .include not working
Really no idea what''s up...
class Auction < ActiveRecord::Base
has_and_belongs_to_many :categories
end
class Category < ActiveRecord::Base
has_and_belongs_to_many :auctions
default_scope order(''title'')
scope :active, where(:active => true)
end
class CategoriesController < ApplicationController
respond_to :html, :json
# GET /categories/:id
2012 Mar 05
8
Create a select with HABM
Hello, I have two tables with association HABM, projects and users, and
in projects I want to show all users that was associated to the project.
I have try with this:
<%= select( "user", "id", Project.all.collect { |p| [ p.name, p.id ] } )
%>
But only show all my projects, but Iz don''t know who show only the user
in a determinated project.
class Project <
2005 Dec 14
0
how to get these records in has_and_belongs_to_many relation
hey,
i my database i have users and groups, each user can get in different groups
my db structure:
table groups: id, name, basegroup, firm_id
table users: id, firstname, lastname, email
table groups_users: group_id, users_id
my relation is a many to many:
class Group < ActiveRecord::Base
has_and_belongs_to_many :users
end
class User < ActiveRecord::Base
has_and_belongs_to_many
2009 Oct 20
2
Find sub sub records
Hi everyone, I have the following problem, maybe someone can help me
figure out what to do.
To simplify my situation, I''m going to make an example of what I need,
this is not the real app structure.
Let''s suppose we have three models, Library, Author, Book.
Manager
has_and_belongs_to_many :area_managers
AreaManager
has_and_belongs_to_many :managers
has_many :employees
2007 Jan 25
1
has_and_belongs_to won't delete records
Hi,
I have a has_and_belongs_to relationship between 2 objects, order and
product. I''m getting a foreign key violation when trying to delete
Order. Is there a special way of deleting orders without deleting
products? ("has_many" has :dependant => :delete_all.... does
"has_and_belongs_to" have something similar)
Trying:
Order.delete_all
Getting:
Mysql::Error:
2013 May 14
5
Why joins queries make result readonly?
Are there any rationalies to make queries obtained by joining scope to be
readonly? I read some old posts (pre-rails3) that joins adds additional
columns to record so that ActiveRecord doesn''t know how to update that
fields, but actually I don''t see that fields. For example I write model
class Order < ActiveRecord::Base
has_and_belongs_to_many :executors, class_name: