similar to: How to determine if an object has just been created

Displaying 20 results from an estimated 6000 matches similar to: "How to determine if an object has just been created"

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
2006 Feb 14
10
acts_as_versioned and getting authors
Hey guys and gals, I have the following object that has acts_as_versioned: class Note < ActiveRecord::Base acts_as_versioned belongs_to :user end The schema for my notes table is as follows: create_table :notes, :force => true do |t| t.column :id, :integer t.column :noteshare_id, :integer t.column :user_id, :integer t.column :title, :string
2007 Nov 14
1
has_many_polymorphs and acts_as_list ?
First, BRAVO for this wonderful plugin: has_many_polymorphs ! Now my problem: 4 models : Collection, Page, Fragment, Belonging (which is the join table): 1 class Collection < ActiveRecord::Base 2 has_many_polymorphs :elements, 3 :through => :belongings, 4 :from => [:pages, :fragments, :collections], 5 :as => :collector, 6 :parent_order =>
2006 Apr 07
6
Multiple view types for a single action?
Is it possible to have more than one kind of view for a specific action, for example an .rhtml and a .rjs file to handle the view for the same action? I suspect not, but this makes me wonder if there a way to call the .rjs file from within the .rhtml so the statements within it get executed? Thanks, Andy
2006 Feb 11
2
Migrations and Unintialized Constants Error
I am running into a problem with two of my tables and the "uninitialized constant" error when using migration. I get the "uninitialized constant Note" when running the following code in my migration file: create_table :notes do |t| t.column :id, :integer t.column :noteshare_id, :integer t.column :title, :string t.column :covered, :string
2006 Apr 08
5
What is the h for?
In the "Agile Web Development with Rails" book it runs through making an example application, a shopping cart. In one of the views files, there is one line of code I dont understand (below), I dont know what the "h" is for, also I took the h out, and it did not affect the application (as far as i could see). <%= h(product.title) %> Can anyone shed some light on this
2006 May 03
6
sql server, date and time
Hey there all, Is there some way to tell rails or sql server to ignore the time in a datetime field when doing a comparison? For example, if I do something like select * from users where registration_date = ?, @date where @date might equal some user input like ''03/14/2006'' The result is nothing returned, because in my tables the datetime field looks like this: 3/14/2006
2006 Feb 17
7
Create and then show
I am attempting to redirect to the show method after creating a new object. So, for example, once a new post is created the user is presented with the new post in a show view. The problem is I can''t get the correct <at> post.id to send to the show method. Rails always returns 0 for this value. Here''s what I have so far: class ContentController < ApplicationController
2007 Jul 19
3
Merb::Controller#url Usage
I have a question about the usage of Merb::Controller#url. When I have nested resources, requesting the new action works differently than I expected. I was wondering what the intended usage is. For example: Say I have r.resources :articles do |article| article.resources :article_attachments end irb(main):002:0> show_routes [:articles, "/articles"] [:article_attachments,
2009 May 25
4
after_create and has_one association bug?
Hello, I''ve come across an issue that I''m sure is a bug when using after_create with a has_one association, but I''m not 100% certain if I''m missing something. This is pretty much exactly the code I''m using. Two simple classes (Account and Contact) and I create the contact after I create an account (via after_create). I''m not passing in a
2006 May 05
2
how to get image properties
Hi friends in PHP there is a direct function GetImageSize(), with it I can easily determine the dimentions of an image file. How can I do in RoR. Please help me out Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060505/13ba1640/attachment.html
2010 Feb 26
2
Fwd: how to install rmagick on fedora please help urgent
hi all i want to run project at local system ..see this i m getting some error http://pastie.org/843746 and when i run server http://pastie.org/843748 plz tell me how to install rmagick on fedora Regards, Shyam +91-9716-18-9650 -- 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
2006 Jul 24
2
Flash problem with RoR? missed something?
I have tried to put a flash movie inside of my RoR page and it shows up with nothing on IEPC. It does very well on every other type of browser but does not work with IEPC. I made a folder - "flash" in my public directory and have had the one instance of it point there. Thus my flash directory is www.rails-app.com/flash/flash.swf Is there anything that anyone knows to help out?
2007 Nov 29
4
collection.build or collection.create gives "ArgumentError: wrong number of arguments (1 for 0)"
I have a Project that has_many Tasks. Tasks belongs to a Project. When I try the following: project = Project.new project.tasks.build I get: >> s = Project.new => #<Project:0x25f9e28 @attributes={"name"=>"", "end_at"=>nil, "updated_at"=>nil, "published_at"=>nil, "user_id"=>nil,
2006 Jul 27
25
Why are has_one objects resaved when the parent is saved?
If the associated object of a has_one association has been loaded, it is resaved when the parent is saved. Eg: class Person < ActiveRecord::Base has_one :user end class User < ActiveRecord::Base belongs_to :person end p = Person.find(:first) p.save # As expected, nothing happens with the user association p.user # Loads the associated object p.save # As well as saving the person, the
2006 May 23
2
Ordinalizing a date
I''m trying to use the ordinalize() method to ordinalize a day. Here''s how far I''ve gotten: @reportday = Time.now.at_beginning_of_week.strftime("%d").to_i @ordinalized_reportday = "#{@reportday}".ordinalize I was thinking it wasn''t working because the date is being returned as a string, however I added the .to_i and still it returns an
2006 Jul 15
4
routing requirements broken in Rails 1.1.4?
Hi, I have the following routes map.connect '':controller/:id/:action'', :id=>/4/, :defaults=>{ :action=>''show''} map.connect '':controller/:action'', :defaults=>{:action=>''index''} and when I point my browser to "localhost:3000/departments" I see an error because the show action cannot find a
2006 Jul 18
16
Session is being shared between tabs!!??
I have just spotted quite a serious problem with my rails app. My app uses the session to store information. Most people who use the app may have more than one instance of it open in their browser (multiple tabs). The session stores which country the user has selected. On each browser tab the user may select a different country. You can add items to a country. There are problems with
2006 Apr 07
4
How to generate mapping with migration
Hi there, I''ve tried to add a m:n mapping table using the migration mechanism. ruby script\generate migration add_categories_notes_mapping and filled the migration file with: class AddNotesCategoriesMapping < ActiveRecord::Migration def self.up create_table :categories_notes do |t| t.column :category_id, :integer, :null=>false t.column :note_id, :integer,
2007 Mar 21
6
Converting Rails app to desktop with XUL?
Hi, We are thinking about choosing Rails as our weapon of choice for our next project, which is basically a text editor on steroids, whith some functionality that need an Internet connection. In the first step we are going to develop it as a plain web app (AJAX-ified, yay!), however, in the next step we would like to port some of the functionality (such as the editor) to a desktop app (which can