Displaying 20 results from an estimated 2000 matches similar to: "How can I set up relations for these models?"
2012 Sep 13
10
access key error
I am getting following error while run my rails app in my server
ActionView::Template::Error (You did not provide both required access keys.
Please provide the access_key_id and the secret_access_key.):
--
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
2005 Dec 19
2
Difficulty using correct moldel for the data in DB
Hi everyone,
I''ve tried posting the same question to the list last Friday but
somehow did not see it being posted..
I''ve just started with Rails and Ruby. I just started to play one of
those RPG and to get my feet wet I''m writing an app to keep track of
item fusions. So the scoop is that item can be fused with another
items to create a higher level item. The higher
2006 Jan 05
13
Naming convention for foreign keys
Hi,
In "Agilge Web Development With Rails" on page 217, an example of
foreign keys is shown.
I am however unable to find a definition of wheater the naming of the
index is significant. On the above mentioned page, this line is shown in
the example:
constraint fk_items_product foreign key (product_id) references
products(id)
In "fk_items_product", "items" is
2007 Apr 11
12
redirection doesn''t get detected well?
I''m doing a redirect in one of my controller actions and somehow I can''t
spec it, see this pastie: http://pastie.caboo.se/53120.
When following the link from a browser I''m being redirected to the right
page.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2006 Jul 13
8
can''t convert true into integer
I have a method:
? def reduceProuctInventoryBy(product_id, reduction)
? ? t=Product.find(:first, :conditions =>["id = ?", product_id])
? ? t.qty=(t.qty-reduction)
? ? t.save
? end
and the model:
class Product < ActiveRecord::Base
? validates_presence_of :qty, :specialDescription
? validates_numericality_of :qty
end
but when i run my method, I get this:
"can''t
2006 Jan 05
2
Agile Depot Tutorial Help
anyone can explain me why in the Agile Depot Tutorial application they
use i.product_id
to find if a product already exist in the cart, because the cart
contains items, each of them references a product.
I tried i.product_id like in the tutorial
and
i.product.i
all of these 2 notation works , but i find the second seems more
clean??? isn''t it.
Any explanation will be fine
Regards
2006 May 04
2
Building a FAQ
I''m new in Rails, and I''m building my first application. I''m trying to make
a FAQ for this application, organized by product (questions about each
product) and category (questions of different categories or topics), and
there is something I can''t figure it out how to do.
I have these tables:
create_table "faqs" do |t|
t.column "question",
2006 Jan 15
6
Saving one-many associations (elegant solution please)
What is the most elegant way to save new one-many associations?
order = Order.new(:name => "My Order")
order.line_items << LineItem.new(:product_id => 1, :quantity => 2)
order.line_items << LineItem.new(:product_id => 2, :quantity => 5)
order.save
The above - which is by far the most elegant way of putting it - doesn''t
work for me - the line_items
2006 Jul 13
1
error_messages_for
I can''t seem to figure out how to validate a few fields some1 please
help me out
model---------
class Record < ActiveRecord::Base
validates_presence_of :sw, :flex
end
controller------------
class RecordController < A;;icationController
def new
@record = Rrecord.new
@product = Product.find(params[''product_id''])
end
def create
2009 Feb 18
3
wrong number of arguments (1 for 0)
Hello,
I am new to ruby on rails. When I tried to create a session I am
getting an error, ''wrong number of arguments (1 for 0)'', in my
controller.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ArgumentError in CustomerController#add_to_cart
wrong number of arguments (1 for 0)
RAILS_ROOT: /project/bob_shopping
Application Trace | Framework Trace | Full
2009 Feb 12
4
routes
I''m trying to figure this.
in my schools controller i want to do this....
# implement a create action to create just the review for the
School...
def create_review_for_a_school
@review = Review.new
@school = School.find(params[:school_id])
@review = @school.reviews.build(params[:review])
if @review.save # The creation worked....do this
flash[:notice] =
2011 Sep 07
4
jquery and ajax query in rails 3
hi people
I don''t know much about ajax - jquery. And right now I need to use
some functionality with them.
In a form (sales model) I have the following code:
<div>
<%= f.label :product_id, "Product" %>
<%= f.collection_select( :product_id, Product.all, :id, :name,
options={} ) %>
</div>
<div>
<%= f.label :price,
2006 Aug 15
3
update or alter cart
I want to modify and update the items in the Depot - "display_cart".
Since the cart is in a session, its a little hard to get at the data.
I just want to create a way to change quantities, prices and
recalculate.
Has someone done this, and could you point me to the right direction.
Thanks
Chas
--
Posted via http://www.ruby-forum.com/.
2006 Nov 29
4
how do I model self-referential entities?
Hi all -
I am having some trouble figuring out how to model self-referential
entities in Rails.
I have a "group" model, which can have 0 or more "group" objects or 0 or
more "user" objects.
I tried creating a subgroup table that has a parent_group_id and a
child_group_id as foreign keys but can''t figure out how to create the
mapping in my ruby model
2012 Oct 22
4
[LLVMdev] Self-referential instruction from jump threading
Hello,
After investigating PR14133, I've discovered that jump threading can output self-referential instructions:
%inc.us = add nsw i32 %inc.us, 1
At least in the test case for that bug report, the relevant code is later deleted (perhaps it is unreachable), and so this does not cause a problem. Unfortunately, when vectorization is enabled, this instruction causes BBVectorize to hang. Should
2006 Aug 02
2
Self-Referential has_many :through
Hello all.
I am trying to create a self-referential has_many :through. I used the
following site as a guide
http://blog.hasmanythrough.com/articles/2006/04/21/self-referential-through
but it still doesn''t appear to be working. I have two models. Person and
Relationship. A person has many contacts (Which is another person)
through relationships
class Person < ActiveRecord::Base
2006 Mar 14
5
GROUP BY and SUM
I have orders, order_items, and products.
I want to collate several orders so that I can get a SUM of quantities
ordered for each product etc.
Can I say something like (the below gives an error on :sum, and ignores
:group)
OrderItem.find(:all, :sum => ''quantity'', :group => ''product_id'',
:include => [:order, :product])
I want to get back a
2006 Jun 05
5
adding habtm through migrations
Hello,
I''m stuck, I''ve got a model Product and would like to add a new model
called Category. Furthermore, I want to set up a many2many
relationship between the mentioned models. the problem is that I do
not know how to set the primary key in the categories_products table.
this is what I''ve got in my migration file:
create_table :categories do |t|
t.column :name,
2006 Aug 13
10
does rails enforce referential integrity???
Hi,
Is rails supposed to support referential integrity? That is rails
either support to be able to ensure that when a new contact is created
this can only happen if a valid suberb is associated with it, and which
mechanisms of the below are supposed to do this?
(a) using DB foreign key constraints information as a basis?
(b) using the "has_one" line in the model file to enfore?
If
2006 Jun 24
2
Migrations problem with Agile Rails book
I am following the instructions on Agile Web Development with Rails book "Iteratio E1: Capturing
an Order" section. When I run the migrations I get the following error.
rake db:migrate
(in /Users/balaparanj/work/depot)
-- execute("alter table line_items \n
add constraint fk_line_item_products \n
foreign key (product_id) references products(id)")
rake