Displaying 20 results from an estimated 10000 matches similar to: "Can save object via console, but not in app's controller"
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
2009 Nov 27
2
update_attribute does not update
My server is running Rails 2.3.4...am I not doing this correctly or is
something borked?
>> c=Contact.last
=> #<Contact id: 24, name: "Larry", email: "larry-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", phone:
2147483647, account_id: 8, created_at: "2009-11-27 18:16:25",
updated_at: "2009-11-27 18:40:08", hide_name: false, hide_phone:
false,
2011 Apr 27
2
Can not create model instance via params on specific model but can on others....
Anyone have an idea on this? Got a weird situation where on a specific model
I can not create an instance using params, yet it works fine on other
models. The model which does not work is a stock model, there is no logic in
it. Ruby 1.8.7/Rails 3.0.5.
Does not work:
(rdb:1) PaymentTransaction.create(:purchase_id => 3)
#<PaymentTransaction id: 2, purchase_id: nil, action: nil, amount: nil,
2008 Oct 06
1
Rails console, saving objects
I was reading a book and following the instructions in it.
>> class Story < ActiveRecord::Base; end
=> nil
>> story = Story.new
=> #<Story id: nil, name: nil, url: nil, created_at: nil,
updated_at: nil>
>> story.class
=> Story(id: integer, name: string, link: string,
created_at: datetime, updated_at: datetime)
I do not remember me asking for id, name, link or
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.
2011 Nov 02
4
undefined method `updated_at' for #<Classified:0x686c5e4>
HEllo, I have the following problem with rails, I am new in this...is
there anyone who explain to me what´s happens?
Thanks
See below:
NoMethodError in Classified#show
Showing app/views/classified/show.rhtml where line #17 raised:
undefined method `updated_at'' for #<Classified:0x686c5e4>
Extracted source (around line #17):
14:
15: <strong>Date Posted:</strong>
2013 May 19
5
update_attributes() for a single column
I was just faced with a strange ROLLBACK exception when attempting to
execute this code:
$ rails console
user = User.first
User Load (1.1ms) SELECT "users".* FROM "users" ORDER BY
"users"."id" ASC LIMIT 1
=> #<User id: 1, name: "Michael Hartl", email: "foo-+RB1Aph5k6s@public.gmane.org",
created_at: "2013-05-12
2006 Jul 07
0
has_many relation handling
Hello,
please have a look at this:
My tables:
create_table :languages do |t|
t.column :name, :string, :limit => 3
t.column :title, :string, :limit => 30
end
create_table :categories do |t|
t.column :category_id, :integer (3.)
t.column :created_at, :timestamp
t.column :updated_at, :timestamp
end
create_table :categorytranslations, :id
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:
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
2006 May 30
3
Help about CMS - newbie in RoR
Hi team, I''m a very newbie RoR user from Spain and I''m developing a
blog''s CMS. Why RoR?, coz I think it''s an amazing framework with many
posibilities, portable and really powerful, with a young and optimist
community, and taking my project I''ve prefered his structure in front of
LAMP. Another thing is that I''ve liked to surprise my masters
2012 Feb 07
2
save method (create action) saves twice
Rails 3.1.3
I have changed a regular scaffold action a bit so that it can save using
ajax.
All I needed to do was adding ":remote => true" in
<div id="script_new">
<%= form_for script, :remote => true do |f| %> <!-- HERE!!! -->
<%= f.hidden_field :video_id %>
<%= f.text_field :text %>
<%= f.submit "save" %>
2006 Jun 05
2
When adding a record in console, a parameter comes in as null even when I set it
In console, I am trying to create a User but the :account_id does not come
in. Console just gives me back :account_id => nil. Obviously I''m trying to
set it though. Silly console...
But, I can set the account_id column in my controller like so:
@user = User.new(params[:user])
@user.account_id = account.id
@user.save
Here''s what I give to the controller:
User.create :name
2009 Aug 28
0
Nil object nightmare
I''m having a real problem with nil objects in a view I''m playing with.
if I type ...
<%= debug lesson.lesson_register.attendees %>
I get the following displayed in the browser ....
- !ruby/object:Attendee
attributes:
enrollee_id: "25"
created_at: 2009-08-27 15:10:41
updated_at: 2009-08-27 15:10:41
id: "1"
attended: f
2010 Jul 05
0
Serialized JSON object importation
Hi,
I would like to import a serialized object (from a JSON export) inside
my database.
It work fine if for instance I do:
>> l = Yea.create(:title => "foo bar")
=> #<Yea id: 3, title: "foo bar", created_at: "2010-07-05 21:44:54",
updated_at: "2010-07-05 21:44:54">
>> j = l.to_json
=>
2007 Apr 22
0
rename error using rebuild_index in console after searching
Hi,
I use ruby console to experiment acts_as_ferret, but I ran into file
rename error when I try to rebuild index after doing a search.
is this normal? I am using Ferret 0.10.9 in windows XP.
Loading development environment.
>> Address.rebuild_index
=> {}
>> Address.find_by_contents(''US'')
=> #<ActsAsFerret::SearchResults:0x4f2ffcc @total_hits=2,
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 Nov 06
0
Nested objects not propagating from view
I thought I had this fixed, but apparently not. It works okay from the
console, but not from the view. I have the following:
# partial schema
create_table "users", :force => true do |t|
t.string "login", :null => false
t.string "first_name"
t.string "last_name"
t.string "email", :null => false
2008 Jan 12
1
Collection_Select not showing Selected option
Hi, I''m having some problem with getting collection_select to return
the current value when editing a record. According to everything I''ve
seen, there was an issue but it''s been fixed, but I can''t figure out
why it isn''t returning the current value as a selected option. I''ve
checked the table structures, and both the call_driver.product_line_id
2009 Apr 29
1
Different behaviour on ActiveResorce with JSON or XML
I''m doing a request from a Rails app to another Rails app with
ActiveResource.
When the format on ActiveResource is XML:
Content.find(:all)[0,2].map(&:attributes)
=> [
{"updated_at"=>Mon Apr 27 15:04:32 UTC 2009,
"url"=>"www.google.com", "id"=>1, "created_at"=>Mon Apr 27 15:04:32
UTC 2009},