[Rails] Validation errors from associated models

2011-08-15 Thread Dennis Schubert
Hey guys, I have a weird problem and I think you are able to solve it easy. I have two models - Posts and Comments. A post :has_many comments and a comment :belongs_to a post. I followed the guide on http://guides.rubyonrails.org/getting_started.html#adding-a-second-model so I added the

[Rails] Re: RegExp error:

2011-08-15 Thread 7stud --
Rafael Ubaldo wrote in post #1016660: It matches because it's true. The expressions states any number of digits before the end of line. It does not state exclusively digits. Wrong. The regex says: 1) match start of line(or just after a newline) 2) match a digit 0 or more times 3) match just

[Rails] Railskit

2011-08-15 Thread MC
Anyone on the list using the current version of Railskit? -- 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 group, send email to

[Rails] Re: RegExp error:

2011-08-15 Thread Frederick Cheung
On Aug 14, 7:29 pm, Misha Ognev li...@ruby-forum.com wrote: Hi! This problem(in model): validates :some_digits_collection, :presence = true, :format = { :with = /^\d*$/, :message = Must contain only digits! } So, :some_digits_collection must match only digits. But when I puts 123f(for

[Rails] Re: Puzzled with form on multiple table rows

2011-08-15 Thread Frederick Cheung
On Aug 14, 7:58 pm, Michael Baldock li...@ruby-forum.com wrote: I've got a table of events, and each event has a boolean attribute is_ten_event. On each row of the table is a chekbox to edit the value of is_ten_event, so that multiple rows can be edited with one submit. In order to allow

Re: [Rails] Re: RegExp error:

2011-08-15 Thread Dheeraj Kumar
Agreed. @OP: You should try this instead: http://edgeguides.rubyonrails.org/active_record_validations_callbacks.html#numericality On Mon, Aug 15, 2011 at 2:41 PM, Frederick Cheung frederick.che...@gmail.com wrote: On Aug 14, 7:29 pm, Misha Ognev li...@ruby-forum.com wrote: Hi! This

[Rails] Re: RegExp error:

2011-08-15 Thread Misha Ognev
^[1-9]\d*$ Walter, thanks for this. Is this column an integer column? If so, then I seem to recall that at the point that validations run rails has already converted the argument to an integer, i.e. it will have converted your 123f to 123 and so your validation passes. Fred, how I can fix

[Rails] Re: sessions store

2011-08-15 Thread Frederick Cheung
On Aug 13, 10:59 pm, Tomas R. li...@ruby-forum.com wrote: i have some questions about sessions store, actually im using cookie based authentication. But i need a way to know if someone is logged in or not, so that's why i need DB store sessions, but my question is, is the a way of making

Re: [Rails] Re: sessions store

2011-08-15 Thread Peter De Berdt
On 15 Aug 2011, at 11:54, Frederick Cheung wrote: On Aug 13, 10:59 pm, Tomas R. li...@ruby-forum.com wrote: i have some questions about sessions store, actually im using cookie based authentication. But i need a way to know if someone is logged in or not, so that's why i need DB store

[Rails] Re: RegExp error:

2011-08-15 Thread Misha Ognev
Dheeraj Kumar, it works, 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 from this group, send email

[Rails] Asset Pipeline pre-processing doesn't clear the cache when dynamic erb is used

2011-08-15 Thread overture
Pre-processing in development mode caches after the first call - which is usually fine - however, when using an erb template with potentially dynamic output, the cache doesn't clear. For example, if I have a javascript file in the asset pipeline called time.js.erb, which outputs an alert with

[Rails] Delayed_Job: code working fine without .delay / with .delay it fails. Why?

2011-08-15 Thread Genji
Hi all, I wrote a simple code to set up the pit_id from a village table from 1 to 2, from 2 to 3 and so on. It works fine without .delay . But i need it so whats wrong with that code? #village_controller def post_info @village = Village.find(params[:id]) @village.delay.upgrade

[Rails] Rackspace, Engine Yard, Heroku, etc. - Which do you recommend?

2011-08-15 Thread Ben Knight
Hello. We are looking for a new provider to host our Rails site -- we have outgrown our current provider (for the past 4 years) since our business is beginning to take off in a big way this year. Which provider (e.g. Rackspace, Engine Yard, Heroku, Serverbeach, etc.) would you recommend to run a

[Rails] Re: Delayed_Job: code working fine without .delay / with .delay it fails. Why?

2011-08-15 Thread Frederick Cheung
On Aug 15, 1:10 pm, Genji sushi.ge...@hotmail.de wrote: Hi all, I wrote a simple code to set up the pit_id from a village table from 1 to 2, from 2 to 3 and so on. It works fine without .delay . But i need it so whats wrong with that code? #village_controller   def post_info    

[Rails] Re: Delayed_Job: code working fine without .delay / with .delay it fails. Why?

2011-08-15 Thread Genji
On 15 Aug., 14:19, Frederick Cheung frederick.che...@gmail.com wrote: On Aug 15, 1:10 pm, Genji sushi.ge...@hotmail.de wrote: Well the problem WAS that it didn't do anything, the worker just told me: [Worker(host:Sascha-Gundels-MacBook-Pro.local pid:961)] 2 jobs processed at 96.8147 j/s, 2

[Rails] How can a User delete another User? | Devise + CanCan

2011-08-15 Thread David Sousa
Hi there, I'm using Devise and CanCan. All my users will be created and manage through my Admin::UsersController by a User that has a Role of Admin. Devise will not register or unregister a User. Every time that a log_in Admin User, that was authenticated ( before_filter :authenticate_user! ),

[Rails] Re: Rackspace, Engine Yard, Heroku, etc. - Which do you recommend?

2011-08-15 Thread Mike C.
There is a little company called Webappcabaret.com that specializes in PAAS. You may give them a try. They use the same cloud infrastructure as the others you mentioned, but I think their PAAS platform is far superior. Ben Knight wrote in post #1016745: Hello. We are looking for a new

[Rails] Rails 3.1 Where to put some application.coffee code ? file tree

2011-08-15 Thread Erwin
In 3.0 we are using an application.coffee file and some specific controllers .coffee files using the following file tree - app - coffescripts application.coffee - controllers control1.coffee control2.coffee In 3.1 , I wonder where I should put

[Rails] respond_with with templates and http status when creating an object

2011-08-15 Thread Michel Pigassou
Hi. When you use respond_with in a controller #create method and want to render XML the response gets the http status 201 (Created). But if you use a view to render this XML response_with uses the status 200 (Ok), for example when you use the gem rabl. I cannot determine if this matter is

Re: [Rails] Re: Long polling (comet) on Rails

2011-08-15 Thread Jeffrey L. Taylor
Quoting Yaroslav Govorunov govoru...@gmail.com: On Aug 14, 1:52 pm, Frederick Cheung frederick.che...@gmail.com wrote: On Aug 11, 12:27 pm, Yaroslav G. li...@ruby-forum.com wrote: [snip] Spreading nodes completely depends on a backend used to store and pass messages - whether it would be

[Rails] gmaps4rails

2011-08-15 Thread bertly_the_coder
Hi guys, I'm trying to use longitude and latitude to center a map like so: %= gmaps(map_options = { auto_zoom = true, center_latitude = 40.7275043, center_longitude = -73.9800645},markers = { data = @json}) % I have tried several variations of the line above, but none of them seem to center the

[Rails] newbie: before_create :setuniqueno

2011-08-15 Thread tom
hi, i was wondering how this should be handled.imagine i have this class: class Invoice ActiveRecord::Base before_create :setuniqueno validates_uniqueness_of :uniquenumber def setuniqueno self.uniquenumber = Time.now.to_i end end ## class TaskActiveRecord::Base end ## after the

[Rails] Re: respond_with with templates and http status when creating an object

2011-08-15 Thread Michel Pigassou
I was able to perform what I'm talking about in an initializer, maybe it can help seeing the big picture: ```ruby ActionController::Responder.class_eval do def to_format if has_errors? api_behavior(nil) and return end controller.response.status = :created if post? !

Re: [Rails] newbie: before_create :setuniqueno

2011-08-15 Thread Philip Hallstrom
i was wondering how this should be handled.imagine i have this class: class Invoice ActiveRecord::Base before_create :setuniqueno validates_uniqueness_of :uniquenumber def setuniqueno self.uniquenumber = Time.now.to_i end end ## class TaskActiveRecord::Base end ##

Re: [Rails] newbie: before_create :setuniqueno

2011-08-15 Thread tom
hi philip so i should use a loop while !@invoice.valid? in the task create action(until its valid?)? thx On Mon, Aug 15, 2011 at 4:29 PM, Philip Hallstrom phi...@pjkh.com wrote: i was wondering how this should be handled.imagine i have this class: class Invoice ActiveRecord::Base

[Rails] Change_column Oracle index limit

2011-08-15 Thread theLemcke
I'm trying to execute a simply change_column on oracle, with the following output: -- change_column(:comments, :text, :string, {:limit=1000}) rake aborted! An error has occurred, this and all later migrations canceled: Index name

Re: [Rails] newbie: before_create :setuniqueno

2011-08-15 Thread Hassan Schroeder
On Mon, Aug 15, 2011 at 12:57 PM, tom tomabr...@gmail.com wrote: class Invoice ActiveRecord::Base before_create :setuniqueno validates_uniqueness_of :uniquenumber def setuniqueno        self.uniquenumber = Time.now.to_i end end after the user post to the create function i also create an

Re: [Rails] newbie: before_create :setuniqueno

2011-08-15 Thread tom
in terms of an invoice i would eg like to display a uniqe number. yes , i could use auto-inc, which is the internal id, but sometimes u just need a ssecond one. so i was wondering how i would generate that during eg a create action. On Mon, Aug 15, 2011 at 4:49 PM, Hassan Schroeder

Re: [Rails] Change_column Oracle index limit

2011-08-15 Thread Hassan Schroeder
On Mon, Aug 15, 2011 at 1:41 PM, theLemcke sixtimesn...@gmail.com wrote: Index name 'temp_index_altered_comments_on_commentable_id_and_commentable_type' on table 'altered_comments' is too long; the limit is 64 characters How do I specify the name of the temporary index in the migration?

Re: [Rails] newbie: before_create :setuniqueno

2011-08-15 Thread Hassan Schroeder
On Mon, Aug 15, 2011 at 1:52 PM, tom tomabr...@gmail.com wrote: in terms of an invoice i would eg like to display a uniqe number. yes , i could use auto-inc, which is the internal id, but sometimes u just need a ssecond one. Still not sure why, but OK -- google `ruby UUID` :-) - Hassan

Re: [Rails] newbie: before_create :setuniqueno

2011-08-15 Thread tom
i know uuid etc. @why sometimes u just need to display another e 10digits number which u can trace back and is still unique @how still not sure if a loop is the right way On Mon, Aug 15, 2011 at 4:59 PM, Hassan Schroeder hassan.schroe...@gmail.com wrote: On Mon, Aug 15, 2011 at 1:52 PM, tom

[Rails] Re: Can't force scaffold to overwrite files?

2011-08-15 Thread Markham A.
Use script/destroy scaffold client admin If you can create it with 'script/generate', you should be able to destroy it with 'script/destroy'. However, there's an inherent inconvenience if you use this with an entity that creates a migration (e.g. model, scaffold). Once you rake the migration,

[Rails] how to get list of Active record fields in database order ?

2011-08-15 Thread Jedrin
If rec is an active record object and you call rec.attribute_names, it gives you the field names in alphabetical order. If there is a way to get the order that the fields where created into the dabatase on the create_table sql call, I would find that very useful. It seems like there is supposed

Re: [Rails] newbie: before_create :setuniqueno

2011-08-15 Thread Hassan Schroeder
On Mon, Aug 15, 2011 at 2:04 PM, tom tomabr...@gmail.com wrote: @why sometimes u just need to display another e 10digits number which u can trace back and is still unique @how still not sure if a loop is the right way You can just try to save and be prepared to catch the validation failure,

[Rails] Re: Change_column Oracle index limit

2011-08-15 Thread theLemcke
Yes, but how do I do this with change_column? On Aug 15, 1:53 pm, Hassan Schroeder hassan.schroe...@gmail.com wrote: On Mon, Aug 15, 2011 at 1:41 PM, theLemcke sixtimesn...@gmail.com wrote: Index name 'temp_index_altered_comments_on_commentable_id_and_commentable_type' on table

Re: [Rails] Re: Change_column Oracle index limit

2011-08-15 Thread Hassan Schroeder
On Mon, Aug 15, 2011 at 3:06 PM, theLemcke sixtimesn...@gmail.com wrote: Yes, but how do I do this with change_column? No idea, and I doubt you can :-) Can you post the migration itself and the current schema for the table? -- Hassan Schroeder

[Rails] Re: how to get list of Active record fields in database order ?

2011-08-15 Thread Jedrin
I wrote this for now, a terrible hack def get_order str = self.inspect ar = str.split(',') ar[0] = ar[0].gsub(/^\S*/,'') ar[ar.length - 1] = ar.last.chop puts 'ar' p ar ar2 = ar.map{|el| el.split(:)[0].strip} puts 'ar2' p ar2 del_idxs = []

[Rails] Re: Change_column Oracle index limit

2011-08-15 Thread theLemcke
You know what? Nevermind. Turns out that table is deleted later in my migrations, so I'll just comment this line out. Still would like to know how to do this, if it's even possible. On Aug 15, 3:17 pm, Hassan Schroeder hassan.schroe...@gmail.com wrote: On Mon, Aug 15, 2011 at 3:06 PM,

[Rails] Best way to create an endless Background job?

2011-08-15 Thread Genji
Hello there, I'm still new to ruby on rails, i try to create a little browsergame. For that, I have to control the resources of a village. For example: The village got a wood rate of 200 per hour, so i want to call every hour a method/action (anything) that count the 200 to the rest wood. But of

[Rails] Re: Best way to create an endless Background job?

2011-08-15 Thread 7stud --
Genji wrote in post #1016820: Hello there, I'm still new to ruby on rails, i try to create a little browsergame. For that, I have to control the resources of a village. For example: The village got a wood rate of 200 per hour, so i want to call every hour a method/action (anything) that

[Rails] Re: newbie: before_create :setuniqueno

2011-08-15 Thread 7stud --
Tom Tom wrote in post #1016803: in terms of an invoice i would eg like to display a uniqe number. yes , i could use auto-inc, which is the internal id, but sometimes u just need a ssecond one. so i was wondering how i would generate that during eg a create action. If you use the internal id,

Re: [Rails] Best way to create an endless Background job?

2011-08-15 Thread Jim Ruther Nill
On Tue, Aug 16, 2011 at 7:09 AM, Genji sushi.ge...@hotmail.de wrote: Hello there, I'm still new to ruby on rails, i try to create a little browsergame. For that, I have to control the resources of a village. For example: The village got a wood rate of 200 per hour, so i want to call every

[Rails] Re: Best way to create an endless Background job?

2011-08-15 Thread 7stud --
Jim ruther Nill wrote in post #1016826: Everytime the page loads The user could have the page open for two hours. What then? -- 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] JQuery dialog not works

2011-08-15 Thread Bruno Meira
Hi guys, I installed JQuery on my rails application, I tested some functions like $(#some_elem).attr(id), and it works well. So, I think that my file was corrected installed. My problem is this: - Everytime that I use JQuery command to create I dialog, this command doesn't works. One example is:

Re: [Rails] JQuery dialog not works

2011-08-15 Thread Bruno Santos
Try autoOpen: true Or create a link that starts the dialog For example: $(a.new_dialog).click(){ $(#test).dialog(open); } 2011/8/15 Bruno Meira goesme...@gmail.com Hi guys, I installed JQuery on my rails application, I tested some functions like $(#some_elem).attr(id), and it

[Rails] Re: JQuery dialog not works

2011-08-15 Thread 7stud --
http://jqueryui.com/demos/dialog/#option-autoOpen -- 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 from this

[Rails] Re: how to get list of Active record fields in database order ?

2011-08-15 Thread 7stud --
Jedrin wrote in post #1016808: If rec is an active record object and you call rec.attribute_names, it gives you the field names in alphabetical order. If there is a way to get the order that the fields where created into the dabatase on the create_table sql call, I would find that very