Displaying 20 results from an estimated 10000 matches similar to: "Create Two objects at the same time"
2011 Oct 02
4
Aggregated attribute changed but _was is changed too. So nothing is update in database.
(Frenchy, sorry =) )
Hi everyone, i''ve got some troubles with aggregated attribute.
I created a point and path class which receive postgresql point and
path type data. Path object contains an array of point object.
I''m currently working on a "hunting" module in web browser based game,
and i need a crontab executed every n minutes to move the character on
the map.
2012 Aug 17
3
Rails doesn't validate create_model or build_model (has_one association)
I''ve got User has_one Shop. Rails is not validating when I tried
create_shop or build_shop, neither in the browser nor the rails console.
My code:
class Shop < ActiveRecord::Base
attr_protected :user_id
belongs_to :user
validates_presence_of :name, :primary_address, :city, :country_code,
:currency
end
class ShopsController < ApplicationController
before_filter
2012 Dec 26
2
has value in a console but it's nil in my controller and my view?
I have this strange behavior and I don''t undertand why. Here is the thing:
I have this record in my payment model:
1.9.3p286 :019 > u.payment.last
Payment Load (0.3ms) SELECT "payments".* FROM "payments" WHERE "payments"."user_id" = 10
=> [#<Payment id: 37, bank_name: "Mercantil", plan: "Plan Uno", date:
2006 Jul 11
1
Problems using the authorization plugin from Bill Katz
Hello everyone,
I was trying to set up access control in a new application Im working on,
I''m trying to use the excellent authorization plugin from Bill Katz,
Its pretty straight forward to setup and should be to use.
But when i try to give the same permission on two differents users on
the same object i get an error.
(Well , Im kinda new to all this rails stuff)
r = Red.find(1)
u1 =
2006 Jan 10
5
Select Tag and Associations
Hi there,
I''ve been working on this for awhile and have finally decided to ask
for a little guidance.I have a slight problem trying to save a
selection.
I have two models:
A "Posting" has_many "Categories", and a "Category" belongs_to one
"Posting". With that said, in the posting model I have "has_many
:categories" and within the
2012 Jun 30
5
Problems with associations
Hello guys, I have two tables, tasks and projects, and each model I put:
Task.rb
class Task < ActiveRecord::Base
attr_accessible :user_id, :project_id, :name
belongs_to :project
end
Project.rb
class Project < ActiveRecord::Base
attr_accessible :name, :description
has_many :tasks
end
But when I go to my prompt and I make a SELECT with task, none project
is returned.
2009 Dec 03
2
Dynamic Paths
Hey there,
I''m in the muck of a major rails project, and need a bit of advice. Google
isn''t much help in this case, so I came here.
I''m trying to set up a URL structure as follows:
url.com/username/blog/post_id
where the user has_many posts and the post belongs_to user. I''m using the
friendly_id plugin to enable easy lookup with the user''s username,
2006 Oct 13
3
Validation errors in has_one/belongs_to relationships.
I have two objects, QuoteInput and Insured.
QuoteInput has one Insured and Insured belongs to QuoteInput.
I don''t understand what I''m seeing.
I assign an Insured to a QuoteInput. The Insured object has invalid
data.
I call save! on the quote input. QuoteInput has no validations.
I expect two things to happen - 1) an exception should be thrown,
indicating that there was a
2010 Jul 20
4
MySQL index question
I am trying to speed up some DB operations and perhaps have gone overboard
with indexes. Does MySQL usually use only one index per query and simply
match keys on the results of the indexed first part? For example:
DELETE FROM tokens WHERE 6813946236211560448 <= fnv AND fnv < 6818449835838930944 AND updated_at<''2010-06-20 14:08:55'' AND occurrences=0;
If I understand
2010 May 11
1
has_one/belongs_to -- accessing the subordinate
With a has_one/belongs_to relationship, what''s the best way to guarantee
that the belongs_to object gets created and is accessible alongside the
has_one object? I *think* the after_create callback is a good choice,
but I discovered an oddity while trying it.
F''rinstance, if every horse has a carriage:
============
ActiveRecord::Schema.define do
create_table(:horses) {|t|
2009 Apr 20
3
xxx.valid? still true after xxx.errors.add(...)?
Hi all
I have the following code in my controller:
if @comment.valid?
captcha_url =
"http://captchator.com/captcha/check_answer/#{captcha_code}/#{@comment.captcha}"
result = open(captcha_url)
unless result.read == "1"
@comment.errors.add(:captcha, "Captcha wurde nicht korrekt
eingegeben")
raise "#{@comment.valid?}"
2008 Jul 13
2
Problem with ActiveRecord::AssociationTypeMismatch
Hi all !
I''ve written a Character model, each character has many Attributes. My
schema.rb looks like this:
create_table "characters", :force => true do |t|
t.string "first_name"
t.string "last_name"
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "attributes",
2005 Dec 19
3
created_on, created_at defaulting to 2000/01/01 00:00:00
Hello all,
Rails 1.0.0
created_on is being set to 2000/01/01 00:00:00
Any ideas on this ?
Thanks!
Schema is
create table user_login_history (
id int identity(1,1) not null,
user_id int not null,
created_on datetime default(getdate()) not null,
created_at datetime default(getdate()) not null,
updated_on datetime default(getdate()) not null,
constraint pk_user_login_history primary key clustered
2006 Aug 15
1
serialisation
the case:
i have two classes:
1)
class Contract < ActiveRecord::Base
serialize :addons
end
2)
class Addon < ActiveRecord::Base
end
Now i do the following in contract_controller:
def create
@contract = Contract.new(params[:contract])
@contract.user_id = session[:user_id]
@contract.customer_id = params[:customer_id]
@contract.pending = 1
@contract.addons = Array.new
end
def update
2011 Jun 11
1
Having a problem adding a foreign key
I keep getting this exception "SQLite3::SQLException: no such
column: books.user_id: SELECT "books".* FROM "books" WHERE
("books".user_id = 4)" ,which sounds like there is no user_id in books
table.So i just installed foreigner plugin and added "
t.integer :user_id, :null => false" and
"add_foreign_key(:books, :users)" in book
2012 Feb 01
12
date validation in rails 3
consider scenario,
User model with name, birth_date fields (here birth_date is not mandatory
field)
inside view form birth_date is assigned as ''31/31/1985'' which is invalid
ideally user object should be invalid and while save raise an error on
birth_date field but that''s not happening and user object gets saved with
birth_date as blank which is completely misleading.
2010 Apr 02
6
App_Controller and partial issues with has_many through
I have a User model, a Post model, and an Interest model:
User has_many posts through interests
User has_many interests, dependent destroy
Post has_many users through interests
has_many interests, dependent destroy
Post has_many interests
Interest belongs to Post
Interest belongs to User
Application_Controller is as follows:
class ApplicationController < ActionController::Base
before_filter
2011 Jul 30
2
Get the current user as Json with Devise
Hi!
I use Devise and Basic HTTP Authentication to access user areas from a
mobile app. When the user enters its details in the app and it tries to
"login" (you don''t actually login with basic auth as you send the
credentials with each request) I want to get a response back with the user
info, like user ID, email (not password) etc.
- So, is there a way to do this out of
2010 Nov 30
4
Cucumber+Capybara rails 3 issue (Don't know where exactly)
When I''m executing cucumber tests, I noticed that sometimes rails app
(in test env.) getting several the same requests (GET or POST) usually
around 3, and it doesn''t render anything with empty HTTP status code.
Have anyone met something similar to that issue?
here is some example of log file:
Started POST "/account" for 127.0.0.1 at 2010-11-30 22:34:17 +0200
2007 Apr 04
1
pontential bug in rspec_on_rails and ActiveRecord transactions
Hello rspec-users,
I''ve encountered a strange bug in rspec, but it may be me who is wrong.
I''m running latest version from the trunk (r1678) of both rspec and
rspec_on_rails.
Please consider the following model:
class Url < ActiveRecord::Base
def after_save
Contact.create!(:primary_email => ''user at example.com'')
raise