[Rails] Re: validates_uniqueness_of - how did I get two users?

2009-03-01 Thread Sarah Mei
In ActiveRecord::Base, the save method takes a flag called perform_validation, which you can set to false. Check your controller code to make sure someone didn't decide to skip the validations somewhere. On Sat, Feb 28, 2009 at 4:39 PM, phil p...@philsmy.com wrote: The odd thing is that the

[Rails] Re: retrieve value from text_field and save it in another model

2009-02-26 Thread Sarah Mei
I'm not quite sure what you're after, but my guess is you want to associate children and filtersetting objects. Have you set up an association in the model files? On Thu, Feb 26, 2009 at 2:04 AM, Swarna Priya rails-mailing-l...@andreas-s.net wrote: I have two models Child.rb and

[Rails] Re: validation + should be 0

2009-02-26 Thread Sarah Mei
You could try making the default value nil. Makes more sense anyway - nil indicates lack of data, while 0 suggests there is a default image. On Thu, Feb 26, 2009 at 12:07 PM, Petan Cert rails-mailing-l...@andreas-s.net wrote: my default value for variable mainimage_id is 0. I am trying to apply

[Rails] Re: controller and views

2009-02-25 Thread Sarah Mei
Check out the complex forms railscast. http://railscasts.com/episodes/73-complex-forms-part-1 On Tue, Feb 24, 2009 at 11:22 PM, Nilesh Kulkarni rails-mailing-l...@andreas-s.net wrote: I am writing an application in which i have list of books fetching from data base,i am using textbox to

[Rails] Re: validation on a has_many relationship

2009-02-25 Thread Sarah Mei
The only think I can think of is that you have a model variable named @request, which is also, by default, the name of the HTTP request object. There may be some weird overwriting going on. Rename your model. It will save you huge headaches in the long run, not least when trying to ask for help,

[Rails] Re: Saving rich text to the database

2009-02-25 Thread Sarah Mei
Couple of questions: first, what happens if you copy and paste the insert SQL into your database and run it (i.e., are you sure the SQL works on your db)? Second, what is in your log after the NoMethodError message? --~--~-~--~~~---~--~~ You received this message

[Rails] Re: Simulating script/console for backend process

2009-02-25 Thread Sarah Mei
Generally, you want to put this sort of thing in a rake task (instead of a script) and then your cron is just cd /application_rails_directory; rake do_my_thing --RAILS_ENV=production On Wed, Feb 25, 2009 at 12:57 PM, Duane Morin rails-mailing-l...@andreas-s.net wrote: I could swear I've seen

[Rails] Re: validation on a has_many relationship

2009-02-24 Thread Sarah Mei
You need to get the contact's errors from the contact. Try this out: @request = Request.new(params[:request]) @request.contacts contact = Contact.new(params[:contact] if @request.save # everything's fine else flash[:error] =

[Rails] Re: Multiple models one form and a one-to-one relationship

2009-02-24 Thread Sarah Mei
In a has_one/belongs_to association, I don't think you need the user= method. What happens if you take it out completely? On Tue, Feb 24, 2009 at 1:27 PM, Stefan Frede sfr...@gmail.com wrote: Hi! I've got a not so unfamiliar multiple models in one form problem. Due to the complex forms

[Rails] Re: best way to model user or IP

2009-02-23 Thread Sarah Mei
Create a single row in the user table to represent the anonymous user, and associate the IP address with the edit instead of with the user. That way you don't clutter your database with anonymous users but you still retain the IP for each edit. On Mon, Feb 23, 2009 at 8:00 AM, Daniel Choi

[Rails] Re: activemerchant + activesupport install/dependency issues

2009-02-23 Thread Sarah Mei
activemerchant requires activesupport = 2.0.0, and that's being loaded ok. Then some other gem is requiring activesupport 1.4.1, but since 2.1.0 is already loaded it can't load 1.4.1. You should run gem cleanup to remove old versions of activesupport. If that doesn't fix it, you'll need to

[Rails] Re: geokit - using :through to connect models

2009-02-23 Thread Sarah Mei
I think your trouble here is with the polymorphic association. (Why do you need it - is there another model that has_one or has_many :internships :as = :employer?) Try either removing :polymorphic = true if you don't need it, or adding :as = :employer to the Employer's has_many :internships

[Rails] Re: Ruby1.9.1 Bus Error

2009-02-23 Thread Sarah Mei
http://redmine.ruby-lang.org/issues/show/1080 http://redmine.ruby-lang.org/issues/show/1142 Ruby 1.8.7 is more stable. On Mon, Feb 23, 2009 at 12:50 PM, Rick richard.t.ll...@gmail.com wrote: More info: In rails (2.3.0) generated test app 1) Ran script/server and default WEBrick started

[Rails] Re: How to set up fixtures to use ActiveRecord callbacks?

2009-02-23 Thread Sarah Mei
I've found the easiest way to do this is to put hashed passwords in the fixtures, i.e. user_1: id: 1 email: u...@mysite.com.test password: ae135e826bbd76cf593d8db38c02ed2e134e159f #test On Mon, Feb 23, 2009 at 1:52 PM, Michael J. I. Jackson mjijack...@gmail.com wrote: Hi all, I have a

[Rails] Re: XMLRPC calling question

2009-02-23 Thread Sarah Mei
erb. Set up a boilerplate file and fill in what you need. It's MUCH faster than trying to generate it with REXML. On Mon, Feb 23, 2009 at 6:57 PM, Don French dhf0...@gmail.com wrote: I have a mashup I need to d with a site that uses xmlrpc. I am trying to understand the the call method. I

[Rails] Re: validation on a has_many relationship

2009-02-23 Thread Sarah Mei
flash[:error] = @request.errors.full_messages.join(', ') On Fri, Feb 20, 2009 at 2:05 AM, Sijo Kg rails-mailing-l...@andreas-s.net wrote:        But here my problem is I expected       'Name should not be blank' 'email should not be blank'     But what I got is    contacts is invalid    

[Rails] Re: How do I access a variable defined in application.rb from within application.rhtml?

2009-02-22 Thread Sarah Mei
For actual read-only data that is an instance of a model class, I'd set up a class method instead. So for a default location, in Location.rb, def self.default_location @@default_location ||= Location.find_by_name(San Francisco) end This fixes your migration problem, doesn't reload it with

[Rails] Re: sorting by subsidiary class

2009-02-22 Thread Sarah Mei
@category = Category.find(params[:id]) @services=Service.find(:all, :order = XXX, :conditions = ['category_id = ?', @category.id]) @category = Category.find(params[:id]) @category.services.sort! { |x, y| x.reduction = y.reduction }