Displaying 20 results from an estimated 80000 matches similar to: "Scope in Rails model vaidation"
2010 Jul 22
9
Something went wrong.
My app works fine in development on my laptop but in production on my
server I get "We''re sorry, but something went wrong. We''ve been notified
about this issue and we''ll take a look at it shortly."
I am using Rails 3, Ruby 1.8.7, Apache and passenger 2.2.15
I get the welcome aboard page in production if I just go to the domain
name but as soon as I want data
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)
2010 Feb 08
5
Why are double sided polymorphic relationships lacking in Rails?
http://stackoverflow.com/questions/2224994/why-are-double-sided-polymorphic-relationships-lacking-in-rails
--
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
2010 Dec 11
3
Why doesn't Heroku show the Rails default page?
Following chapter (1) of the Ruby on Rails tutorial:
http://railstutorial.org/, I was able to successfuly push the
application to "Heroku" using:
> git push heroku master
But, when I open the website, I get a page with the following:
App crashed
This application is temporarily offline.
If you''re the administrator of this app, please check your heroku logs
for the backtrace.
2013 Jul 19
12
Rails 4 "belongs_to: record" association doesn't work
Hi,
I discovered a weird behavior when using a "belongs_to: record" association
in Rails 4.
Given two models A and B:
class A < ActiveRecord::Base
belongs_to :record, class_name: ''B'', foreign_key: ''b_id''
end
class B < ActiveRecord::Base
end
When creating A, it inserts a record in B and returns A with id of nil:
irb(main):001:0>
2010 Dec 14
5
Build associated model confusion
I''m new to Rails3, and I''m just trying to get one last thing to work
before I call it a night. The situation is the following (please if
the code is horrible, just let me know, still learning):
I want to log a dive. I might have a new location on that dive at
which point I have to create a new Location, and then create the dive.
A dive has_one location. A location has_many
2013 Feb 25
3
ActiveRecord associations: design question
Hi guys,
In my Rails app, I have three models: A, B and C, with the following
relationships:
- B hasMany C
- C belongsTo B
I would like A to "has_one" instance of B+C. By that I mean A needs to
be linked to a specific instance of B AND a specific instance of C.
My first guess would be to create a fourth object, say B_plus_C that
would:
- belongs to B
- belongs to C
- belongs to A
Is
2012 May 27
3
Dumb question
Folks
Can a model just have a belongs_to only? or do you have to have a
belongs_to and a has_many or has_one on the other model?
--
Posted via http://www.ruby-forum.com/.
--
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
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
2010 Mar 17
3
Associating a default paperclip image from a different model
Here''s some code, this is my NewsItem model as you can see...
class NewsItem < ActiveRecord::Base
belongs_to :country
has_attached_file :image, :styles => { :original => ''57x57'' },
:default_url => ''/images/football.png''
# has_attached_file :image,
# :styles => { :original => ''57x57'' },
2011 Jan 15
3
has_many :through with Single Table inheritance
I have the following model structure setup.
class User < ActiveRecord::Base
end
class Parent < User
has_many :relationships
has_many :children,
:class_name => "Student",
:through => :relationships,
:conditions => "related_as = ''parent''"
end
class Student < User
has_many :relationships
2010 Dec 06
10
testing chapter: agile web dev withrails
I am working my way through Agile web development with rails and I''m in
the testing chapter.
when I run the following test(or any other test)
I''m new and not sure where to start looking.
require ''test_helper''
class ProductTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
I
2011 Apr 11
4
Printing field attributes outside the model.find_by_sql
Hi All,
I have Model called pays..and it has fields like(id, topic, subject,
created_at, b_id) and i also have a Model called suggests with
fields(id, income, price, b_id)
In my ruby on rails action or method Controller:
def print_two_table
@p = Pay.find_by_sql("SELECT p.id, p.topic, s.id, s.income, s.price FROM
pays as P LEFT OUTER JOIN suggests AS s ON s.b_id = p.b_id WHERE
2011 Feb 26
1
How to manage the form of a model that has two foreign keys
Hi,
Basically I have two models: User and Godfather. The godfather table
has three columns:
- user_id (FK --> User)
- user_godfather_id (FK --> User)
- description (text)
Inside each model class, I am adding the following associations:
class User < ActiveRecord::Base
has_many :godfathers # for user_id
has_many :godfathers, :foreign_key =>
2011 Feb 05
4
Questions about Chapter 9: Sign in, Sign out of RoR Tutorial | Learn Rails by Example
Hello
Finished reading chapter 9 and im a little bit confused.
1. In the tutorial, Modules are used instead of creating a Model and
working in a class inside a module , like in authenticating passwords.
Wouldn''t that be possible? Or is it unnecessary since we''re not
messing with a database in terms of storing data?
2. what is the difference between session[:remember_token] =
2010 May 14
4
Tricky model situatione
I have two models Club and users. users are regular authenticated
users and some of them might create a club. A club can also have
members (essentially users) and there are attributes and models that
apply to member but not to users.
Here is what I have right now.
Club => belongs_to :user
User => has_many clubs (since a user can host multiple clubs).
Now how do I fit this member model
2010 Mar 01
3
has_many models in a form
Hi, guys.
There are four models in the program, A has_many B through C, B has_many
A through C, A has_many D, D belongs_to A. I have a form to create A.
Inspired by Ryan Bates'' railscasts I was able to create A and D in the
same form, and link A to B(created beforehand) through C in the same
form as well. Is it possible to create A and B in the same form?
Thanks in advance.
--
Posted
2012 Oct 11
4
what;s the right url in this case
Hello,
I have this models
class Berichten < ActiveRecord::Base
attr_accessible :bericht, :user
belongs_to :user
belongs_to :Category
end
class User < ActiveRecord::Base
attr_accessible :email, :name
has_many :berichten
end
class Category < ActiveRecord::Base
attr_accessible :id :name
has_many :berichten
end
What I wonder is what the right url is when I want to place a
2011 Jan 10
8
Creating a Dynamic/Custom form
I am pretty new at rails and seem to be stuck on an issue.
Trying to find a way to get me app admin to create a form on our rails
app. These would include:
- Select form control type
- Select required validation
- Select price change if selected
How should I even start going at this?
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk"
2012 Feb 12
3
Rails routes - destroy
Can''t figure out how duplicate routes are differentiated by rails ...
Read routing from inside out and API as well as a few tutorials but
still don''t get it!!! For example...
routes.rb
resources :minisections do
resources :questions
end
rake routes:
minisection_question GET
/minisections/:minisection_id/questions/:id(.:format)
questions#show