[Rails] Re: eager loading with has_many :through

2009-02-25 Thread Frederick Cheung
On Feb 25, 4:46 am, shenry stuarthe...@gmail.com wrote: Currently I'm doing:   Photo.find(:all, :include = :parent, :conditions ['thumbnail = ?', 'small']) but I can't figure out how to eager-load the albums, through slides, based on the parent photo (since the thumbnail doesn't have

[Rails] Re: Ajax response strip script tag from response

2009-02-25 Thread Frederick Cheung
On Feb 25, 1:26 am, Rémi Gagnon rails-mailing-l...@andreas-s.net wrote: An newbie question.  I have a script tag included in the response of an ajax call (from a link_to_remote) But this script tag is in the response(seen in firebug) but not on the webpage.  It is stripped by something. I

[Rails] Re: render :update problem

2009-02-25 Thread Frederick Cheung
On Feb 24, 10:49 pm, Me chabg...@gmail.com wrote: I am baffled because in the view I do this: $('shelfcards').update(%= render :partial = 'turin2000' %); Gives me nothing in the div. Think about what actually ends up in the page: $('shelfcards').update(fieldset/fieldset) Clearly that

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

2009-02-25 Thread Tonypm
hi, Ruby pocket reference looks useful, think I'll order a copy. Regarding the class method, just wondering when/how this method should get called. Tonypm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on

[Rails] Nested Resources and Routes

2009-02-25 Thread Sahil Dave
hi, i have some nested resources like, a deal has_many :orders and has_one :invoice i am using nested routing for these. so the urls are like: deals_url deal_orders_url deal_invoice_url and others for the whole CRUD although everything is working perfectly, the updates for a nested resource

[Rails] Re: validation on a has_many relationship

2009-02-25 Thread Priya Buvan
Hi, Try the following @request.contacts.errors.each{} -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ 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

[Rails] authentication and user management questions

2009-02-25 Thread sa 125
Hi - I am using a fairly standard authentication in my app (user model, before_filter in application_controller). This authentication is taken almost entirely from the 3rd ed. of the agile web dev w/ rails. A few questions about all that - 1. I'm still in dev environment, but I noticed that I'm

[Rails] Re: complex forms and :index = nil issues

2009-02-25 Thread sa 125
I read that rails 2.3 will handle nested models seamlessly with accepts_nested_attributes_for inside the parent model (http://guides.rubyonrails.org/2_3_release_notes.html). Any idea when the final 2.3 is going to be released (currently in RC1)? -- Posted via http://www.ruby-forum.com/.

[Rails] Re: validation on a has_many relationship

2009-02-25 Thread Sijo Kg
Again error undefined method `errors' for #Class:0xb67d8848 -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ 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

[Rails] Re: authentication and user management questions

2009-02-25 Thread MaD
for your permissions problem I'd suggest the implementation of roles or groups. that way you can add users to groups or give them roles, which can be checked in a before_filter in your controllers. sessions: if you are using activerecordstore (and thus your sessions are saved in a db-table)

[Rails] Wiki kind of features

2009-02-25 Thread Sandeep Gudibanda
Hi, We are planning to implement a wiki kinda feature on a company page. The details of the company can be edited/updated by any. Is there a nice n clean way to do this feature? Any suggestions? Regards, SG -- Posted via http://www.ruby-forum.com/.

[Rails] Association through 2 intermediate Models

2009-02-25 Thread sol
Hey, I have an association chain like this: Site has_many Feed(s) has_many FeedEntry(/ies) has_many Articles where the reverse is always belongs_to: Article belongs_to FeedEntry belongs_to Feed belongs_to Site Now what I want is to get all articles that belong to a specific Site, something

[Rails] Re: authentication and user management questions

2009-02-25 Thread sa 125
MaD wrote: for your permissions problem I'd suggest the implementation of roles or groups. that way you can add users to groups or give them roles, which can be checked in a before_filter in your controllers. I thought about creating groups, but then won't this complicate things? I'll have

[Rails] Multiple rows in a model

2009-02-25 Thread Swarna Priya
Hi, I am new to rails. Any support from your side would be very helpful. I have two models one named Child.rb and the other named Filtersetting.rb The general idea is one user can have many children and one child can have one Filtersetting. Hence i have done with the User model. Now while

[Rails] Re: Strange error when running rails 2.3 on ruby 1.9.1 on FreeBSD

2009-02-25 Thread Conrad Taylor
On Tue, Feb 24, 2009 at 6:34 AM, Grzesiu x...@poczta.onet.pl wrote: Conrad, I am sure that the fork command works fine on Ruby 1.9.1. What I meant is that it doesn't work on FreeBSD port of Ruby 1.9.1, whereas it works on that port in version 1.8.7. Both versions were installed in the same

[Rails] Re: Ajax response strip script tag from response

2009-02-25 Thread Rémi Gagnon
Thank you Frederick, That means I can't have an other ajax call within an ajax response. Its odd. In my case I have 'tabs' and the action of these tabs are in ajax, within these tabs I have an auto complete field. How can I make this work? Thank you Rémi Frederick Cheung wrote: I

[Rails] Re: Ajax response strip script tag from response

2009-02-25 Thread Frederick Cheung
On 25 Feb 2009, at 11:20, Rémi Gagnon wrote: Thank you Frederick, That means I can't have an other ajax call within an ajax response. With prototype it's just the default. You don't have to have it that way (don't know about jQuery) Its odd. In my case I have 'tabs' and the action of

[Rails] Re: render :update problem

2009-02-25 Thread Jeremy Olliver
Do note, that this is not really ajax. The point of ajax, and more importantly the use of rendering a partial is that when you make the request you are not reloading the entire page, but rather using javascript to send a request to the server in the background while the existing page doesn't

[Rails] Re: validation on a has_many relationship

2009-02-25 Thread Priya Buvan
Sijo Kg wrote: Again error undefined method `errors' for #Class:0xb67d8848 Just give contacts.errors.each{} -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on

[Rails] Re: validation on a has_many relationship

2009-02-25 Thread Sijo Kg
undefined local variable or method `contacts' for #RequestsController:0xb67de400 -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to

[Rails] gem install mysql -- Error

2009-02-25 Thread Sankar Kumar
Hi, When I try to install gem install mysql it throwing error. For your ref, bash-2.05b$ gem install mysql -- --with-mysql-dir=/opt/etrade/p6/share/mysql5 ERROR: http://gems.rubyforge.org/ does not appear to be a repository ERROR: could not find gem mysql locally or in a repository

[Rails] InvalidAuthenticityToken error with db sessions

2009-02-25 Thread sa 125
I added login to my app and storing the sessions in the db. I un-commented the config.action_controller.session_store = :active_record_store line in the environment.rb file, and the :secret in the application.rb file. Now, when I try to login I get the error InvalidAuthenticityToken. Here's my

[Rails] Re: gem install mysql -- Error

2009-02-25 Thread TonyBacellar
Hellow Sankra ! Try sudo gem install mysql Tony Bacellar tonybacel...@gmail.com http://delicious.com/tonybacellar On Feb 25, 10:10 am, Sankar Kumar rails-mailing-l...@andreas-s.net wrote: Hi, When I try to install gem install mysql it throwing error. For your ref, bash-2.05b$ gem install

[Rails] Problem with set_table_name

2009-02-25 Thread Sarathy .n
Dear friends, I ran the following in my console.Assume I already have the postgresql connection . class D ActiveRecord::Base end = nil D.set_table_name users = nil D.column_names = [id, name, fname, lname, password, addr1, addr2, city, state, email, created, gender]

[Rails] Re: Association through 2 intermediate Models

2009-02-25 Thread sol
sorry, what? On Feb 25, 1:55 pm, Priya Buvan rails-mailing-l...@andreas-s.net wrote: you can use through na.. -- Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on

[Rails] Re: InvalidAuthenticityToken error with db sessions

2009-02-25 Thread sa 125
sa 125 wrote: I added login to my app and storing the sessions in the db. I un-commented the config.action_controller.session_store = :active_record_store line in the environment.rb file, and the :secret in the application.rb file. Now, when I try to login I get the error

[Rails] How to resolve JavaScripts Conflict

2009-02-25 Thread Salil Gaikwad
How to resolve the javascripts conflicts between jQuery.js and prototype.js. Thanks Salil -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To

[Rails] Re: authentication and user management questions

2009-02-25 Thread MaD
I thought about creating groups, but then won't this complicate things? I'll have group_pages table, and how do I manage those? can a user belongs to many groups? it's actually best to create a many-to-many relationship (user habtm groups). there are many plugins outthere that provide just

[Rails] Saving rich text to the database

2009-02-25 Thread David
I've started trying to use the wysihat rich text editor from 37- signals and everything is going well except that I get an error when trying to save the text from the enhanced field to the database. This is from my log: Processing InstructionsController#new (for 127.0.0.1 at 2009-02-25

[Rails] Re: gem install mysql -- Error

2009-02-25 Thread Sankar Kumar
TonyBacellar wrote: Hellow Sankra ! Try sudo gem install mysql Tony Bacellar tonybacel...@gmail.com http://delicious.com/tonybacellar On Feb 25, 10:10�am, Sankar Kumar rails-mailing-l...@andreas-s.net I'm not having sudo access to my box. But I have did all the previous step without

[Rails] Re: Multiple rows in a model

2009-02-25 Thread MaD
in which line do you get the error? probably here: @child = Child.new(params[:child]) or here: @filter = Filtersetting.new(params[:filtersetting]) use the debugger (set it before that line) to see what's in your params-hash. there is probably a key like :1 = something then you can find

[Rails] Re: InvalidAuthenticityToken error with db sessions

2009-02-25 Thread MaD
i answered to this in your other thread... --~--~-~--~~~---~--~~ 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 rubyonrails-talk@googlegroups.com To unsubscribe from this

[Rails] Re: How to resolve JavaScripts Conflict

2009-02-25 Thread Conrad Taylor
On Wed, Feb 25, 2009 at 5:57 AM, Salil Gaikwad rails-mailing-l...@andreas-s.net wrote: How to resolve the javascripts conflicts between jQuery.js and prototype.js. Hi, what conflict you're having in regards to jQuery and prototype? I'm guess that you're talking about the use of $(...).

[Rails] Re: ar_mailer issue - emails not getting saved into DB

2009-02-25 Thread Filippo Camillo
Hi, somethings new? Thank you! Filippo Sean Mcgilvray wrote: Where you able to fix this problem? I am having the same issues. Thank you, Sean McGilvray -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you

[Rails] Re: Association through 2 intermediate Models

2009-02-25 Thread sol
Hi, On Feb 25, 2:34 pm, Conrad Taylor conra...@gmail.com wrote: Hi, I recommend reading AWDwR 3ed on using 'has_many through' for the details. These details are the reason I'm asking :) is this: http://agilewebdevelopment.com/plugins/nested_has_many_through still the only way to do this? or

[Rails] Re: Redirect_to Vs Render_component

2009-02-25 Thread Srividya Sharma
I tried using the flash message, but the data that I need to pass is huge. so, I get a cookie overflow error. This technique did not work out for me. Is there anything else I could use? I just recalled that render_component is deprecated in 2.2.2 and a plug-in has to be used to get the same

[Rails] Routes with parameters ordered differently

2009-02-25 Thread Kailas Narendran
Hi, i'm trying to setup a custom route and having some trouble. In various resources i've seen plenty of examples of how to do something along the lines of: map.connect foo/bar/:a/:b/:c, :controller = foo, :action = bar, (and :a,:b and :c get mapped to params[]) what i'd like to do is make

[Rails] Re: render :update problem

2009-02-25 Thread Chris Habgood
Ya, I am not doing an ajax call because it is not really needed. I can possibly have new equipment and that would require more maintenance to tell the ajax call where to go for that piece of eqpt. The way I am doing would just require an array entry and a controller action. Anyway, I got it to

[Rails] Re: How to resolve JavaScripts Conflict

2009-02-25 Thread Salil Gaikwad
Thanx 2 both of u for a quick reply. My problem is if Both libraries included then only first library works. i.e. if i include prototype.js then jQuery.js then only prototype.js works. on change select list and toggle box which used jQuery.js doesn't work. Conrad Taylor wrote: On Wed, Feb

[Rails] Re: Count array keys possible?

2009-02-25 Thread Maurício Linhares
departures = [ 'AMS', 'BCN', 'BBK' ] sums = {} departures.each do |d| sums[d] ||= 0 sums[d] = sums[d] + 1 end puts( sums ) - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Tue, Feb 24, 2009 at 2:57 PM, Remco Swoany

[Rails] what's happened to acts_as_state_machine

2009-02-25 Thread John Small
I went to get the latest acts_as_state_machine from http://github.com/rubyist/aasm/tree/master and to my untrained eye it appears not to work anymore. At least it doesn't work the same way that the old acts_as_state_machine worked and there's no explanation for getting the new stuff running in an

[Rails] Re: How to resolve JavaScripts Conflict

2009-02-25 Thread Salil Gaikwad
i am using.. Prototype JavaScript framework, version 1.6.0.1 jQuery 1.2.3 - New Wave Javascript rails-2.0.2 -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on

[Rails] Re: Wiki kind of features

2009-02-25 Thread Maurício Linhares
Install mediawiki and look at it's database, probably the best source of ideas. - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Wed, Feb 25, 2009 at 6:46 AM, Sandeep Gudibanda rails-mailing-l...@andreas-s.net wrote: Hi, We are planning to

[Rails] Re: creating a rails plugin

2009-02-25 Thread Maurício Linhares
Usually, plugins do it by using polymorphic associations, so they don't need to know in advance the real class that's going to be referenced. - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Wed, Feb 25, 2009 at 1:21 AM, Amita Bhatkhande

[Rails] Re: Search engine that works with MS SQL Server

2009-02-25 Thread Maurício Linhares
Why don't you use a full text search engine that doesn't require a database - http://lucene.apache.org/solr/ Can't understand why people still try to use Sphinx, when it doesn't get any near Solr's features and doesn't update the indexes on the fly. - Maurício Linhares

[Rails] Re: How to resolve JavaScripts Conflict

2009-02-25 Thread CFC
I will include jquery first, than include prototype: head %= javascript_include_tag jquery % scriptvar $j = jQuery.noConflict(); /script %= javascript_include_tag prototype % /head or You can write jQuery code by this way: script (function($){/* Write jQuery Codes in here */})(jQuery);

[Rails] Re: Background browser independent Application

2009-02-25 Thread Salil Gaikwad
is it possible using Http request or something like that. Thanks in Advance -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this

[Rails] Secure but elegant destruction method

2009-02-25 Thread Vahagn Hayrapetyan
Hi,- I am looking for a clean and secure way for an ActiveRecord instance to delete itself. Say I have a User model in my app. Then the destructive action would be /users/user_id/destroy. If this action is not secured by a filter like: (*) before_filter :check_administrator_role, :only =

[Rails] Re: eager loading with has_many :through

2009-02-25 Thread shenry
Sweet, thanks Fred. On Feb 25, 12:02 am, Frederick Cheung frederick.che...@gmail.com wrote: On Feb 25, 4:46 am, shenry stuarthe...@gmail.com wrote: Currently I'm doing:   Photo.find(:all, :include = :parent, :conditions ['thumbnail = ?', 'small']) but I can't figure out how to

[Rails] Simulating script/console for backend process

2009-02-25 Thread Duane Morin
I could swear I've seen instructions before on how to do this, but I can't find them. I've got a backend process that runs in the same environment as my webapp, injecting data into the model. In the interests of not repeating myself I'd like to take advantage of the app/models from my webapp as

[Rails] Re: Secure but elegant destruction method

2009-02-25 Thread Vahagn Hayrapetyan
Sorry, the code should have been: def destroy @user = User.find(params[:id]) if @user == logged_in_user or logged_in_user.has_role?('administrator') if @user.destroy flash[:notice] = User deleted else flash[:error] = There was a problem deleting this user.

[Rails] Re: Count array keys possible?

2009-02-25 Thread Remco Swoany
Maurício Linhares wrote: departures = [ 'AMS', 'BCN', 'BBK' ] sums = {} departures.each do |d| sums[d] ||= 0 sums[d] = sums[d] + 1 end puts( sums ) - Maur�cio Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Tue, Feb 24, 2009 at 2:57

[Rails] Re: Search engine that works with MS SQL Server

2009-02-25 Thread Maurício Linhares
And it still is faster at indexing, as it isn't capable of on-the-fly updates (if something changes, you´ll have to rebuild your index). I see Sphinx as an option if your full text search functionality isn't that complicated (Sphinx can't do partial matches or fuzzy search) or your indexed

[Rails] Re: Count array keys possible?

2009-02-25 Thread Maurício Linhares
Why don't you do it at the database with an order by? - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Wed, Feb 25, 2009 at 1:04 PM, Remco Swoany rails-mailing-l...@andreas-s.net wrote: Maurício Linhares wrote: departures = [ 'AMS', 'BCN',

[Rails] Re: Wonky Validation, attr_accessor

2009-02-25 Thread Maurício Linhares
Here's how it should look like: class User ActiveRecord::Base validates_length_of :password, :within = 5..40 validates_uniqueness_of :email validates_presence_of :email, :password validates_confirmation_of :password, :if = :password_changed? #require confirmation only if it has changed

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

2009-02-25 Thread Maurício Linhares
Go to your RAILS_ROOT folder and then: script/runner here goes the name of your script -e production Read the help: script/runner -h Usage: script/runner [options] ('Some.ruby(code)' or a filename) -e, --environment=name Specifies the environment for the runner to operate under

[Rails] Re: ar_mailer issue - emails not getting saved into DB

2009-02-25 Thread Sandeep Gudibanda
Hi, Do you have action_mailer_tls installed too? I guess that did the trick! but its been a while I solved it. Lemme know if it works for you. Regards, Sandeep G -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because

[Rails] Re: Count array keys possible?

2009-02-25 Thread Remco Swoany
Maurício Linhares wrote: Why don't you do it at the database with an order by? - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Wed, Feb 25, 2009 at 1:04 PM, Remco Swoany hmm...i don't now how to count the values through the

[Rails] Re: ar_mailer issue - emails not getting saved into DB

2009-02-25 Thread Filippo Camillo
Thank you Sandeep...i solved using rails 2.1.1 instead of 2.2.2! I suppose that there are some incompatibility issues. Many thanks! Filippo Sandeep Gudibanda wrote: Hi, Do you have action_mailer_tls installed too? I guess that did the trick! but its been a while I solved it. Lemme know if

[Rails] Re: ar_mailer issue - emails not getting saved into DB

2009-02-25 Thread Sandeep Gudibanda
Great! sgudiba...@gmail.com is my email. Do keep in touch. Filippo Camillo wrote: Thank you Sandeep...i solved using rails 2.1.1 instead of 2.2.2! I suppose that there are some incompatibility issues. Many thanks! Filippo Sandeep Gudibanda wrote: Hi, Do you have action_mailer_tls

[Rails] Re: Count array keys possible?

2009-02-25 Thread Maurício Linhares
Ok, so this is the best time to start learning SQL, here's a good start - http://oreilly.com/catalog/9780596526849/ Here's how the query would look like: SELECT departure, COUNT(*) AS departures_count FROM bookings GROUP BY departure - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br)

[Rails] Dynamic database connection

2009-02-25 Thread Rick Fiorentino
Hi All, Is there a way to determine the adapter type, as well as, other information on the fly for a database? For example, can you make a generic type connection to a database (assuming the db server port and/or credentials are correct) and ask the db information about itself, then based on the

[Rails] Re: InvalidAuthenticityToken error with db sessions

2009-02-25 Thread sa 125
Right, sorry. Thought it might deserve a seperate thread. Here's the other post if someone wondered here looking for an answer: http://www.ruby-forum.com/topic/179690#786710 -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this

[Rails] Re: Count array keys possible?

2009-02-25 Thread Rob Biedenharn
On Feb 25, 2009, at 11:37 AM, Maurício Linhares wrote: Ok, so this is the best time to start learning SQL, here's a good start - http://oreilly.com/catalog/9780596526849/ Here's how the query would look like: SELECT departure, COUNT(*) AS departures_count FROM bookings GROUP BY departure

[Rails] Re: what's happened to acts_as_state_machine

2009-02-25 Thread Robert Walker
John Small wrote: I went to get the latest acts_as_state_machine from http://github.com/rubyist/aasm/tree/master and to my untrained eye it appears not to work anymore. At least it doesn't work the same way that the old acts_as_state_machine worked and there's no explanation for getting the

[Rails] Re: Implementing a web service in rails

2009-02-25 Thread Robert Walker
Ryan Leary wrote: Thanks Robert, I'll look into your tips tomorrow and let you know how it goes. I actually need to provide the web service. I would like to use REST, but my web service must fit the signature above. The client that wants to consume this web service uses SOAP. I've had

[Rails] Re: Displaying line breaks paragraphs using 'simple_format' ?

2009-02-25 Thread Gavin
Hey Tom- sadly I noticed this same issue with simple_format I get around it by adding a model method to whatever the class is with the text. For example, if I have pages, and each page has a body, I'll add a method like so: class Page def format_breaks body.gsub(\n, br /) end end and

[Rails] Re: Nested Resources and Routes

2009-02-25 Thread Richard Aday
You need to change the way you reference orders so that you scope an order within a deal. Give this a shot and let me know if it works: order_controller.rb: Index action: @order = @deal.orders.find(:all) Show action: @order = @deal.orders.find(params[:id]) New action: @order =

[Rails] Re: Joining three objects uniquely using :has_many

2009-02-25 Thread Evan
Andrew, Changing the scope of validates_uniqueness_of to product_id solved my problem. Thank you. Evan On Feb 21, 8:32 pm, Andrew Bloom akbl...@gmail.com wrote: I'm not sure I'm 100% clear, but it sounds like you are saying that a Repair may only have one combination of Part/Product, and it

[Rails] Re: what's happened to acts_as_state_machine

2009-02-25 Thread John Small
It morphed into aasm: http://github.com/rubyist/aasm/tree/master Yes I know that, because that's where I got the gem from. What I need to know is how to get the thing working with AR because the extremely slim example given in the readme just plain does not work. Does anyone know the ins

[Rails] Lockdown: Understanding nil_lockdown_values...?

2009-02-25 Thread gberz3
Hi All, I'm having a bit of trouble wrapping my head around nil_lockdown_values in the Lockdown plugin. I'm unfamiliar with how exactly this works. I'm assuming it is a helper method of sorts, but I see no definition. Does Rails simply have the ability to nil_ [somerandomliborclass]_values?

[Rails] Migration : value between 1 and 7

2009-02-25 Thread Guillaume Loader
Hello everyone! I want to add a column to a table. So here is my migration. My question is : Is it possible to say that this value must be between 1 and 7 and must no be a float (1.4 shouldn't be possible) ? class AddValueToTable ActiveRecord::Migration def self.up add_column :table,

[Rails] Re: what's happened to acts_as_state_machine

2009-02-25 Thread Rick
I use aasm with restful-authentication which gem has some info on getting aasm to work. I'm not sure if rest-auth's info is redundant with other gems but it works for me. I've used it with Ruby 1.8.[67] and 1.9.1 and Rails 2.[12].2 and 2.3.0. Check out the README.textile. On Feb 25, 8:35 am,

[Rails] Re: Migration : value between 1 and 7

2009-02-25 Thread Philip Hallstrom
I want to add a column to a table. So here is my migration. My question is : Is it possible to say that this value must be between 1 and 7 and must no be a float (1.4 shouldn't be possible) ? class AddValueToTable ActiveRecord::Migration def self.up add_column :table, :value, :int

[Rails] Re: Migration : value between 1 and 7

2009-02-25 Thread Maurício Linhares
This isn't someithing to be done inside a migration, but at your model as a validation: class Table validates_inclusion_of :value, :in = (1..7).to_i end - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Wed, Feb 25, 2009 at 3:49 PM,

[Rails] Re: Migration : value between 1 and 7

2009-02-25 Thread Maurício Linhares
Ops, it's a to_a class Table validates_inclusion_of :value, :in = (1..7).to_a end - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Wed, Feb 25, 2009 at 3:54 PM, Maurício Linhares mauricio.linha...@gmail.com wrote: This isn't someithing to

[Rails] Re: Migration : value between 1 and 7

2009-02-25 Thread Guillaume Loader
I'm using mySQL. Can I add a parameter :min and :max? -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ 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

[Rails] Re: Migration : value between 1 and 7

2009-02-25 Thread Guillaume Loader
Ok so I''ll dot it at my model. Thank you! -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ 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

[Rails] Re: Migration : value between 1 and 7

2009-02-25 Thread Guillaume Loader
Maurício Linhares wrote: Ops, it's a to_a Why do we need to_a? -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send

[Rails] Re: Migration : value between 1 and 7

2009-02-25 Thread Maurício Linhares
'Cos: (1..7).include?( 2.2 ) is true, but (1..7).to_a.include?( 2.2 ) isn't. - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Wed, Feb 25, 2009 at 4:02 PM, Guillaume Loader rails-mailing-l...@andreas-s.net wrote: Maurício Linhares wrote:

[Rails] Re: Migration : value between 1 and 7

2009-02-25 Thread Rick
Add to model validates_numericality_of :value, :only_integer = true, :less_than_or_equal_to = 7, :greater_than_or_equal_to = 1 to get the inclusive [1-7] int only On Feb 25, 8:49 am, Guillaume Loader rails-mailing-l...@andreas- s.net wrote: Hello everyone! I want to add a column to a

[Rails] Re: what's happened to acts_as_state_machine

2009-02-25 Thread John Small
Rick wrote: Check out the README.textile. On Feb 25, 8:35�am, John Small rails-mailing-l...@andreas-s.net I checked out the README.textile for restful_authentication, which doesn't really say anything about aasm. The generator just generates code for the old aasm, which doesn't work with

[Rails] Re: Displaying line breaks paragraphs using 'simple_format' ?

2009-02-25 Thread Tom Ha
Thanks, Gavin! That definitely helps... -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ 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

[Rails] find_or_create_by_...

2009-02-25 Thread Jo Jo
If I use find_or_create_by_.. is it possible to define at was it created or founded? -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to

[Rails] Cancel the last migration?

2009-02-25 Thread Guillaume Loader
Hello everyone! How can I cancel the last migration? Thank you! -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send

[Rails] Re: Cancel the last migration?

2009-02-25 Thread Maurício Linhares
rake db:rollback - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Wed, Feb 25, 2009 at 4:26 PM, Guillaume Loader rails-mailing-l...@andreas-s.net wrote: Hello everyone! How can I cancel the last migration? Thank you! -- Posted via

[Rails] Re: Cancel the last migration?

2009-02-25 Thread Guillaume Loader
Thanks! -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ 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 rubyonrails-talk@googlegroups.com To unsubscribe

[Rails] Re: find_or_create_by_...

2009-02-25 Thread Phlip
Jo Jo wrote: If I use find_or_create_by_.. is it possible to define at was it created or founded? Could you ask the question a different way? Are you trying to do this (WARNING: made up!)... find_or_create( my_by_var, 42 ) ...such that you can vary my_by_var, and create by different

[Rails] Re: find_or_create_by_...

2009-02-25 Thread szimek
Hi, I'm not exactly sure what you're asking about, but if you want to find out if the result was already in the db or was it just created, you could use find_or_initialize_by instead: post = Post.find_or_initialize_by_title(something completely different) post.new_record? # false if it was

[Rails] Re: what's happened to acts_as_state_machine

2009-02-25 Thread szimek
The way it is now written there shouldn't be any difference between using aasm with AR and any other Ruby class. Here's very basic example from our User model: class User ActiveRecord::Base include AASM aasm_column :state # I guess it's the only AR specific method here

[Rails] Re: Search engine that works with MS SQL Server

2009-02-25 Thread Carsten Gehling
Maurício Linhares wrote: Solr is a full blown full text search tool with most of the features you'll see in enterprise tools like fuzzy searching (that enables ... I will give Solr a go, thanks. One of the things I like about ThinkingSphinx though is the ability to combine Sphinx's free-text

[Rails] Re: find_or_create_by_...

2009-02-25 Thread Phlip
szimek wrote: post = Post.find_or_initialize_by_title(something completely different) Way! Now try this: post = Post.find_or_create_by_title(completely different) do |post| p post.new_record? end does that print a true? (Trick question, BTW!;) -- Phlip

[Rails] local variables in partials lead to NameError

2009-02-25 Thread Jamie Forrest
I know I must be doing something dumb, but I can't seem to send a local variable to my partial. The below code leads to the following error: NameError in Residential_listings#new undefined local variable or method `foo' for #ActionView::Base: 0x3fb53f8 I am trying to call the variable 'foo' in

[Rails] Re: local variables in partials lead to NameError

2009-02-25 Thread Jodi Showers
Jamie On 25-Feb-09, at 3:25 PM, Jamie Forrest wrote: I am trying to call the variable 'foo' in a partial called _attachment.html.erb, which is nested in another partial called _form.html.erb. In _form.html.erb, I have: %= render( :partial = 'listings/attachment',

[Rails] Multiple DBs and Query Cache

2009-02-25 Thread Andrew Selder
Hi all, I have an application where the majority of models live in one main DB, while I have a couple model relying on data in a old DB. So I created an abstract class for those models and called establish_connection() to the old DB. So far so good. I'm running some fairly repetitive queries

[Rails] Re: local variables in partials lead to NameError

2009-02-25 Thread Jamie Forrest
does %= foo % work? Sorry that was a typo in my original message. I have %= foo % in my partial and it doesn't work. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this

[Rails] Getting started, sort of

2009-02-25 Thread bachcole
I was working with: The Rails Cookbook A Ruby on Rails Crash Course Brian Hogan http://www.napcs.com/resources/rails/cookbook/rails_cookbook.pdf page 5 And I did this: C:\rubygem install sqlite3-ruby And I got this: Building native extensions. This could take a while... ERROR: Error

[Rails] on Ultrasphinx Associations

2009-02-25 Thread SergioMB
I am new to ultrasphinx and I am struggling with this issue. I ve got a model with the following associations and is_indexed options: class Item has_many :keywords is_indexed :fields = ['id', 'collection_id','subject_area', 'special_interest', 'notes', 'abstract'], :concatenate =

[Rails] Adding a monkey patch

2009-02-25 Thread Vinay Bg
Hi /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/connection_adapters/mysql_adapter.rb (class Mysql adapter) there is a call def create_table(table_name, options = {}) #:nodoc: super(table_name, options.reverse_merge(:options = ENGINE=InnoDB)) I have a monkey patch

[Rails] Re: Adding a monkey patch

2009-02-25 Thread Vinay Bg
config/initializers :) and it works!! Vinay Bg wrote: Hi /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/connection_adapters/mysql_adapter.rb (class Mysql adapter) there is a call def create_table(table_name, options = {}) #:nodoc: super(table_name,

  1   2   >