[Rails] Re: I'm restarting to work with ruby on rails, but having configurations problems
On 26 set, 02:47, Delirium tremens wrote: > On 26 set, 02:29, Delirium tremens wrote: > > > > > I have the Shovell source code from the book Simply Rails 2, but I'm > > having problems running it. > > > "Getting started > > Here’s how to get rolling: > > > 1. > > Create your databases and edit config/database.yml > > > Rails needs to know your login and password. > > 2. > > Use script/generate to create your models and controllers > > > To see all available options, run it without parameters. > > 3. > > Set up a default route and remove or rename this file > > > Routes are set up in config/routes.rb." > > > I took step 1, then since the models and controllers are already > > generated for a source code that already exists, I skipped step 2 and > > since a default route is already set for a source code that already > > exists, I skipped step 3. > > > My config/roubes.rb has map.root :controller => "stories", > > buthttp://localhost:3000/stilldoesn't load the stories controller > > index. Why? > > I hadn't deleted public/index.html, but now I'm getting the error > messagehttp://pastie.org/631341How to solve? After deleting public/index.html, I renamed application.rb to application_controller.rb, then used rake to migrate my data with rake db:migrated and it worked! --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: I'm restarting to work with ruby on rails, but having configurations problems
On 26 set, 02:29, Delirium tremens wrote: > I have the Shovell source code from the book Simply Rails 2, but I'm > having problems running it. > > "Getting started > Here’s how to get rolling: > > 1. > Create your databases and edit config/database.yml > > Rails needs to know your login and password. > 2. > Use script/generate to create your models and controllers > > To see all available options, run it without parameters. > 3. > Set up a default route and remove or rename this file > > Routes are set up in config/routes.rb." > > I took step 1, then since the models and controllers are already > generated for a source code that already exists, I skipped step 2 and > since a default route is already set for a source code that already > exists, I skipped step 3. > > My config/roubes.rb has map.root :controller => "stories", > buthttp://localhost:3000/still doesn't load the stories controller > index. Why? I hadn't deleted public/index.html, but now I'm getting the error message http://pastie.org/631341 How to solve? --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] I'm restarting to work with ruby on rails, but having configurations problems
I have the Shovell source code from the book Simply Rails 2, but I'm having problems running it. "Getting started Here’s how to get rolling: 1. Create your databases and edit config/database.yml Rails needs to know your login and password. 2. Use script/generate to create your models and controllers To see all available options, run it without parameters. 3. Set up a default route and remove or rename this file Routes are set up in config/routes.rb." I took step 1, then since the models and controllers are already generated for a source code that already exists, I skipped step 2 and since a default route is already set for a source code that already exists, I skipped step 3. My config/roubes.rb has map.root :controller => "stories", but http://localhost:3000/ still doesn't load the stories controller index. Why? --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: uniqueness validation perplexity
Dudebot wrote: [...] > Frederick--I'm not sure how to use > validates_uniqueness_of with more than one field--can that be done? I'm going to suggest that you spend less time posting here and more time reading docs. 20 seconds of reading the documentation for validates_uniqueness_of would have told you about the :scope option. Look it up. :) > > Again, many thanks, > Craig > > On Sep 25, 9:35�pm, Frederick Cheung Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: uniqueness validation perplexity
Many thanks, Colin & Frederick--I ended up with this: def position_in_category_not_unique @items = Item.find( :all, :conditions => [ "category_id = ? AND position = ?", category_id, position ] ) single = Item.first( :all, :conditions => [ "category_id = ? AND position = ?", category_id, position ] ) if @items.size > 1 || ( single && single.id != id ) errors.add_to_base "Position #{ position } already exists in # { Category.find( category_id ).header }." end end Which works, but seems ugly. Frederick--I'm not sure how to use validates_uniqueness_of with more than one field--can that be done? Again, many thanks, Craig On Sep 25, 9:35 pm, Frederick Cheung wrote: > On Sep 26, 12:14 am, Dudebot wrote: > > > > > > > I want to write a validate routine to check to enforce that a position > > must be unique in a category. (In another category, it doesn't have > > to and shouldn't need to be unique.) I write this code which works > > happily for new items: > > > def position_in_category_not_unique > > @items = Item.find( :all, :conditions => [ "category_id = ? AND > > position = ?", category_id, position ] ) > > if @items.size > 0 > > errors.add_to_base... > > > If, however, I try to *update* an existing item, because it's already > > in the database, it gives the error. > > > Any suggestions on how to approach this? It's a conceptual question. > > Do I handle this through the controller somehow? > > You could add a condition along the lines of AND id != self.id. Or > you could use validates_uniqueness of, which already handles this. > > Fred > > > > > Many, many, many TIA if you tackle this one :) > > Craig --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Widgets
Sandip Ransing wrote: > Have a look at browsercms in rails > > Sandip > > On Wed, Sep 23, 2009 at 5:17 PM, Smit Shah > > wrote: > >> > -- > Ruby on Rails Developer > http://funonrails.wordpress.com > www.joshsoftware.com > http://brandpotion.com (Latest project released) Hey... Thanks buddy... But I m looking for any site that provides step by step instructions for creating widgets in rails... -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: uniqueness validation perplexity
On Sep 26, 12:14 am, Dudebot wrote: > I want to write a validate routine to check to enforce that a position > must be unique in a category. (In another category, it doesn't have > to and shouldn't need to be unique.) I write this code which works > happily for new items: > > def position_in_category_not_unique > @items = Item.find( :all, :conditions => [ "category_id = ? AND > position = ?", category_id, position ] ) > if @items.size > 0 > errors.add_to_base... > > If, however, I try to *update* an existing item, because it's already > in the database, it gives the error. > > Any suggestions on how to approach this? It's a conceptual question. > Do I handle this through the controller somehow? > You could add a condition along the lines of AND id != self.id. Or you could use validates_uniqueness of, which already handles this. Fred > Many, many, many TIA if you tackle this one :) > Craig --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: customize active record attribute display name in error message
I responded just a bit ago, but I don't see my response, so hopefully there won't be two responses... Essentially, Drew, you can map the column to be something else when you call "humanize" on it. Try this: class Post < ActiveRecord::Base HUMANIZED_COLUMNS = {:msg => "Message"} def self.human_attribute_name(attribute) HUMANIZED_COLUMNS[attribute.to_sym] || super end end HTH, Richard On Fri, Sep 25, 2009 at 4:49 PM, drewB wrote: > > Is there an easy way to customize the display name of the attributed > used in a validation error message. For example, let's say I have an > active record with the attribute :msg that is validated for presence. > If is doesn't exist I don't want the user to see "msg can't be > blank!" I want it to say "Message can't be blank!" Is there an easy > way to do that? > > > --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: customize active record attribute display name in error message
I responded just a bit ago, but I don't see my response, so hopefully there won't be two responses... Essentially, Drew, you can map the column to be something else when you call "humanize" on it. Try this: class Post < ActiveRecord::Base HUMANIZED_COLUMNS = {:msg => "Message"} def self.human_attribute_name(attribute) HUMANIZED_COLUMNS[attribute.to_sym] || super end end HTH, Richard On Sep 25, 4:49 pm, drewB wrote: > Is there an easy way to customize the display name of the attributed > used in a validation error message. For example, let's say I have an > active record with the attribute :msg that is validated for presence. > If is doesn't exist I don't want the user to see "msg can't be > blank!" I want it to say "Message can't be blank!" Is there an easy > way to do that? --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] I've been trying to reply to a post, but none of my responses are taking...
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/cf59e09f98981f27/42caa6a0b45fd271#42caa6a0b45fd271 I've been trying to say this: I responded just a bit ago, but I don't see my response, so hopefully there won't be two responses... Essentially, Drew, you can map the column to be something else when you call "humanize" on it. Try this: class Post < ActiveRecord::Base HUMANIZED_COLUMNS = {:msg => "Message"} def self.human_attribute_name(attribute) HUMANIZED_COLUMNS[attribute.to_sym] || super end end HTH, Richard On Sep 25, 4:49 pm, drewB wrote: > Is there an easy way to customize the display name of the attributed > used in a validation error message. For example, let's say I have an > active record with the attribute :msg that is validated for presence. > If is doesn't exist I don't want the user to see "msg can't be > blank!" I want it to say "Message can't be blank!" Is there an easy > way to do that? When I respond either through the web interface or in email, it says it's successful (in the browser), but my answers are not listed... this was hours ago. Do I need to gain approval before posting responses? --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: customize active record attribute display name in error message
Hi drewB, You can change the "humanized" version of that symbol when it's accessed via human_attribute_name. Try this: class Post < ActiveRecord::Base HUMANIZED_COLUMNS = {:msg => "Message"} def self.human_attribute_name(attribute) HUMANIZED_COLUMNS[attribute.to_sym] || super end end HTH, Richard On Sep 25, 4:49 pm, drewB wrote: > Is there an easy way to customize the display name of the attributed > used in a validation error message. For example, let's say I have an > active record with the attribute :msg that is validated for presence. > If is doesn't exist I don't want the user to see "msg can't be > blank!" I want it to say "Message can't be blank!" Is there an easy > way to do that? --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: ActiveRecord in a generator?
Hey Colin, In my generator I am creating some migrations, amongst other things, and then dropping into the shell to run rake db:migrate. After that, I want to seed the new table with a single record. What's the best way to do that from the generator? Thanks, Elliott On Sep 25, 7:54 pm, Colin Curtin wrote: > On Fri, Sep 25, 2009 at 4:05 PM, elliottg wrote: > > How would one access ActiveRecord methods inside of > > Rails::Generator::NamedBase? > > What kind of methods are you hoping to access? Or really, what are you > trying to accomplish? > > Colin --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: customize active record attribute display name in error message
I am aware of the :message option. What I was hoping to do is be able to use many of the default messages and just change the attribute name displayed. For example, something like: attr_display_name :msg "Message" On Sep 25, 3:31 pm, Greg Donald wrote: > On Fri, Sep 25, 2009 at 4:49 PM, drewB wrote: > > > Is there an easy way to customize the display name of the attributed > > used in a validation error message. For example, let's say I have an > > active record with the attribute :msg that is validated for presence. > > If is doesn't exist I don't want the user to see "msg can't be > > blank!" I want it to say "Message can't be blank!" Is there an easy > > way to do that? > > Have you read the validation documentation? > > All of the Rails validators support a :message option, for example > look at validates_presence_of: > > http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMeth... > > See where it says "message - A custom error message (default is: > "can‘t be blank")." ? That means when you write > > validates_presence_of :foo, :message => "Message can't be blank!" > > -- > Greg Donaldhttp://destiney.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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: exists? weirdness
On Sep 25, 2009, at 7:05 PM, Dudebot wrote: > This works: > > @items = Item.find( :all, :conditions => [ "category_id = ? AND > position = ?", category_id, position ] ) >if @items.size > 0 ... > > But this: > > if Item.exists?( :conditions => [ "category_id = ? AND position = ?", > category_id, position ] )... Try it like: Item.exists?(["category_id = ? AND position = ?", category_id, position]) Or: Item.exists?(:category_id => category_id, :position => position) It wants the *value* of the conditions key in the options hash. -Rob > > Gives this error despite the documentation for Active Record Query > Interface which says > "Further more, exists takes a conditions option much like find:"... > > SQLite3::SQLException: no such column: items.conditions: SELECT > "items".id FROM "items" WHERE ("items"."conditions" IN ('category_id > = ? AND position = ?',4,3.0)) LIMIT 1 > > Any idea why? > > Many TIA, > Craig > > Rob Biedenharn http://agileconsultingllc.com r...@agileconsultingllc.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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Segmentation fault when loading fixtures
On Fri, Sep 25, 2009 at 3:50 PM, Greg Lazarev wrote: > > I successfully loaded about 35K records. It's really when it gets above > 100k that it seg faults. What version of Ruby are you on? Could it be a particular fixture that is segfaulting YAML? Can you do a binary search and pinpoint exactly how many fixtures until segfault? Colin --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: uniqueness validation perplexity
On Fri, Sep 25, 2009 at 4:14 PM, Dudebot wrote: > If, however, I try to *update* an existing item, because it's already > in the database, it gives the error. What error are you seeing? What code are you running to update the item? > Any suggestions on how to approach this? It's a conceptual question. > Do I handle this through the controller somehow? If it's a validation check, it should be in the model. Colin --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: ActiveRecord in a generator?
On Fri, Sep 25, 2009 at 4:05 PM, elliottg wrote: > How would one access ActiveRecord methods inside of > Rails::Generator::NamedBase? What kind of methods are you hoping to access? Or really, what are you trying to accomplish? Colin --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] uniqueness validation perplexity
I want to write a validate routine to check to enforce that a position must be unique in a category. (In another category, it doesn't have to and shouldn't need to be unique.) I write this code which works happily for new items: def position_in_category_not_unique @items = Item.find( :all, :conditions => [ "category_id = ? AND position = ?", category_id, position ] ) if @items.size > 0 errors.add_to_base... If, however, I try to *update* an existing item, because it's already in the database, it gives the error. Any suggestions on how to approach this? It's a conceptual question. Do I handle this through the controller somehow? Many, many, many TIA if you tackle this one :) Craig --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] exists? weirdness
This works: @items = Item.find( :all, :conditions => [ "category_id = ? AND position = ?", category_id, position ] ) if @items.size > 0 ... But this: if Item.exists?( :conditions => [ "category_id = ? AND position = ?", category_id, position ] )... Gives this error despite the documentation for Active Record Query Interface which says "Further more, exists takes a conditions option much like find:"... SQLite3::SQLException: no such column: items.conditions: SELECT "items".id FROM "items" WHERE ("items"."conditions" IN ('category_id = ? AND position = ?',4,3.0)) LIMIT 1 Any idea why? Many TIA, Craig --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] ActiveRecord in a generator?
How would one access ActiveRecord methods inside of Rails::Generator::NamedBase? Thanks, Elliott --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Segmentation fault when loading fixtures
I successfully loaded about 35K records. It's really when it gets above 100k that it seg faults. -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: dynamic form problem
On Fri, Sep 25, 2009 at 3:25 PM, Greg Donald wrote: > > On Fri, Sep 25, 2009 at 4:37 PM, Jedrin wrote: >> try. Having empty tags in the > > Empty tags is invalid HTML. Use a non-breaking space or > something similar to make it valid. > > ?? I assumed the OP meant "empty" but what you propose above is totally invalid -- the only children of a TR are TD or TH. An NBSP is character data, not white-space. -- Hassan Schroeder hassan.schroe...@gmail.com twitter: @hassan --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Cheapest Rails Hosting where they give you full access to Apache (to load modules etc)???
Agreed. Rackspace is great. Especially when you're 1st building your application. I had apache/passenger and mysql running just fine on a 256MB instance. cost? about $11/month. http://www.tonycode.com/blog/archives/122 There is EC2 on Rails but AWS starts at about $90/month. I'm really happy with rackspace. On Sep 25, 6:18 pm, Greg Donald wrote: > On Fri, Sep 25, 2009 at 4:43 PM, Greg Hauptmann > > wrote: > > > any pointers / suggestions re cheapest Rails hosting where they give > > you full access to Apache (to load modules etc)??? Can be a shared > > platform, however not sure if there is a shared platform type hosting > > service where they do give you such access? > > Cloud hosting is probably the cheapest you'll find where you have root > access. I'm using Rackspace Cloud. > > http://www.rackspacecloud.com/ > > -- > Greg Donaldhttp://destiney.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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Segmentation fault when loading fixtures
On Fri, Sep 25, 2009 at 4:28 PM, Greg Lazarev wrote: > I'm on windows XP and used the Task Manager to see if memory was peaking > out, it wasn't. How else can I tell if a specific process is running out > of memory? Can you do smaller load tests and extrapolate up from there ? Does 10K also segfault? -- Greg Donald http://destiney.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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: customize active record attribute display name in error message
On Fri, Sep 25, 2009 at 4:49 PM, drewB wrote: > > Is there an easy way to customize the display name of the attributed > used in a validation error message. For example, let's say I have an > active record with the attribute :msg that is validated for presence. > If is doesn't exist I don't want the user to see "msg can't be > blank!" I want it to say "Message can't be blank!" Is there an easy > way to do that? Have you read the validation documentation? All of the Rails validators support a :message option, for example look at validates_presence_of: http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M002164 See where it says "message - A custom error message (default is: "can‘t be blank")." ? That means when you write validates_presence_of :foo, :message => "Message can't be blank!" -- Greg Donald http://destiney.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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: dynamic form problem
On Fri, Sep 25, 2009 at 4:37 PM, Jedrin wrote: > try. Having empty tags in the Empty tags is invalid HTML. Use a non-breaking space or something similar to make it valid. -- Greg Donald http://destiney.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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Cheapest Rails Hosting where they give you full access to Apache (to load modules etc)???
On Fri, Sep 25, 2009 at 4:43 PM, Greg Hauptmann wrote: > > any pointers / suggestions re cheapest Rails hosting where they give > you full access to Apache (to load modules etc)??? Can be a shared > platform, however not sure if there is a shared platform type hosting > service where they do give you such access? Cloud hosting is probably the cheapest you'll find where you have root access. I'm using Rackspace Cloud. http://www.rackspacecloud.com/ -- Greg Donald http://destiney.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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: dynamic form problem
On Fri, Sep 25, 2009 at 2:37 PM, Jedrin wrote: > > Maybe what it is is I can't generate any or tags in my > partial that renders the ajax stuff. If any empty ones I have won't > show as a row until I render into them, maybe that is what I should > try. Having empty tags in the original and then render into > the inside of them with ajax .. I'm guessing that might solve my > problem .. I can't see the presence or absence of a table being relevant unless you're creating mal-formed markup with your AJAX results. In which case all bets are off :-) Are you using Firebug? If not, stop, get it, use it. And it would be useful if you either posted the app somewhere public or created a downloadable test case that demonstrates the issue. -- Hassan Schroeder hassan.schroe...@gmail.com twitter: @hassan --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Drop down list ?
The weird thing is that it is working now with f.collection_select :category_id, Category.all, :id, :header instead of f.collection_select :category_id, Category.all, :id, :header, {}, :multiple => false so :multiple => false seems to be the problem. But why? Is this a bug? Again, many thanks, Craig On Sep 25, 2:54 pm, Colin Law wrote: > 2009/9/25 Dudebot : > > > > > > > > > Thanks again, Colin--in item.rb: > > > belongs_to :category > > > And in category.rb: > > > has_many :items > > > Item has a field category_id which I intended to populate with the > > links from an item to its category. The field header in the category > > db is where the name of the category is. > > > Am I setting it up wrong then to have: > > > <%= f.collection_select :category_id, Category.all, :id, :header, > > {}, :multiple => false %> > > > in the form? It does show up as a drop down box with the names > > populated in it. > > That should be fine as far as I can see, though I don't understand the > extra [] in the html you showed. One question, you said that it is > not saving the new category id value, are you sure that it is not > saving it, or is it possibly just not displaying it when you come > round next time. Have a look in the db to see. > > Another question, in an earlier post you showed the record being saved > by update_attributes, what are you doing if that fails? In other > words is the save succeeding? > > I am getting to the point where I don't know what is happening I am afraid. > > Colin --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] customize active record attribute display name in error message
Is there an easy way to customize the display name of the attributed used in a validation error message. For example, let's say I have an active record with the attribute :msg that is validated for presence. If is doesn't exist I don't want the user to see "msg can't be blank!" I want it to say "Message can't be blank!" Is there an easy way to do that? --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Cheapest Rails Hosting where they give you full access to Apache (to load modules etc)???
any pointers / suggestions re cheapest Rails hosting where they give you full access to Apache (to load modules etc)??? Can be a shared platform, however not sure if there is a shared platform type hosting service where they do give you such access? --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: how can I use Apache to serve static content for a RoR app when I have only .htaccess access (and can't add Apache modules) [on Dreamhost shared server]
thanks Matt 2009/9/26 Matt Jones : > > Note that the X-Sendfile method in the linked article is only > supported by an Apache module, which doesn't appear to be installed on > the default DH config. So you're back where you started... > > I'd recommend contacting DH support - I've never worked with them, but > the support at Site5 has always been willing to install gems / Apache > modules that were standard. > > --Matt Jones > > On Sep 25, 1:53 pm, Greg Hauptmann > wrote: >> thanks Casey - you no doubt correct :) I'll run with your suggested >> 'don't over-engineer' concept... >> >> 2009/9/25 daphonz : >> >> >> >> >> >> >> >> > Greg, >> >> > It sounds like you have a contradicting desire here. You say you want >> > the uploads to be served directly by the Apache server (so you don't >> > have Rails touching it), but you still want some form of >> > authentication to make sure people can access it (which I imagine is >> > what your Rails app is doing). >> >> > The overhead from processing a Rails request is quite minimal, >> > especially is you're just doing some sort of user authentication and >> > not some complex query/data gathering. My recommendation would be to >> > use something like Paperclip (http://www.thoughtbot.com/projects/ >> > paperclip) to help you upload files to your webserver, but protect >> > access by serving the files through a Rails controller (something like >> > this:http://www.therailsway.com/2009/2/22/file-downloads-done-right). >> >> > And again, if you're really, really concerned about your server >> > overhead (like you'll be getting tens of thousands of requests per >> > hour), you can always move some of this logic into Rails Metal to >> > decrease the overhead, but, again, it's unlikely that you'll need to >> > do so. >> >> > -Casey >> >> > On Sep 24, 4:52 pm, Greg Hauptmann >> > wrote: >> >> (bump - still really interested in response if someone is knowable in >> >> this area) >> >> >> 2009/9/23 Greg Hauptmann : >> >> >> > Hi, >> >> >> > Are there any Rails/Apache guru's that might know if it's possible >> >> > (and how) to have the ability for users to upload their content to my >> >> > RoR application but then subsequent access to such static content >> >> > would be: >> >> >> > a) served by APACHE web server [to avoid the overhead of going via >> >> > Rails], but >> >> > b) still want to have an authentication/authorisation check to >> >> > occur before they can access the content >> >> >> > The constraint is I'm onhttp://dreamhost.com/sharedplatform where I >> >> > have only access to the Apache .htaccess file and I can't add my own >> >> > Apache modules. >> >> >> > http://wiki.dreamhost.com/Apache >> >> > http://wiki.dreamhost.com/Htaccess >> >> > http://wiki.dreamhost.com/KB_/_Unix_/_.htaccess_files >> >> >> > thanks >> >> >> -- >> >> Greghttp://blog.gregnet.org/ >> >> -- >> Greghttp://blog.gregnet.org/ > > > -- Greg http://blog.gregnet.org/ --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: dynamic form problem
Maybe what it is is I can't generate any or tags in my partial that renders the ajax stuff. If any empty ones I have won't show as a row until I render into them, maybe that is what I should try. Having empty tags in the original and then render into the inside of them with ajax .. I'm guessing that might solve my problem .. --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Segmentation fault when loading fixtures
Marnen Laibow-Koser wrote: > Is the process running out of memory, perhaps? I'm on windows XP and used the Task Manager to see if memory was peaking out, it wasn't. How else can I tell if a specific process is running out of memory? -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Segmentation fault when loading fixtures
Greg Lazarev wrote: > I created some performance fixtures that load around 100k+ items through > a fixture. While the fixture is loading I get a seg fault: > /ruby/lib/ruby/1.8/yaml.rb:133: [BUG] Segmentation fault > > Would anyone be able to shine some light on this problem? Can fixtures > not load that much data? Is the process running out of memory, perhaps? > What are my alternatives to load performance > data? Machinist and Faker might be worth a look. Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Segmentation fault when loading fixtures
I created some performance fixtures that load around 100k+ items through a fixture. While the fixture is loading I get a seg fault: /ruby/lib/ruby/1.8/yaml.rb:133: [BUG] Segmentation fault Would anyone be able to shine some light on this problem? Can fixtures not load that much data? What are my alternatives to load performance data? -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: dynamic form problem
I didn't quite understand what you meant. However, this whole approach is having numerous problems, though I did get an rjs focus to work. I'm not sure if it's because there is a table inside the form, but the basic thing is I want to change form fields using ajax. If you have a some text fields and some selects like say: <%= select_tag :data_format, options_for_select (['t1','b1','ascii'],@fmt) %> <%= select_tag 'transaction[level]', options_for_select (['','level-1','level-2'], level) If you select ascii, I want to dynamically change the transaction [level] select to be a different set of selections through an observer. and then add a checkbox: <%= check_box_tag 'transaction[EOG]', eog, checked %> It doesn't seem to work that I can update part of a form when there is a table involved. If I try to re render the whole form, the current problem is that I send the data back from the form_observer, but say a user types in an input field and he types 'abc'. The observer calls the server and sends 'abc', but after that he types 'xyz'. The server in this strategy will re render the form, and that field will go back to 'abc' erasing part of the users input. When I have tried to just use field observers and save all the fields in session variables, if I have a button that looks like a submit button, what sometimes happens is the user can rapidly type something and hit the submit button and submit will fire before the observer and it won't submit all of the data. The page I'm having the problem with seemed like it was working ok along time ago until someone may have changed it, they may have added a table. I'm not sure, but it may be the table that is giving me the trouble. On Sep 25, 2:46 pm, Hassan Schroeder wrote: > On Fri, Sep 25, 2009 at 9:29 AM, Jedrin wrote: > > I don't suppose there is any easy way to tell what the focus was when > > observe_form sends the call to the server ? > > Uh, the suggestion in my previous message? :-) > > -- > Hassan Schroeder hassan.schroe...@gmail.com > twitter: @hassan --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] nested model form error messages
I have a form that updates 3 models. To the end user its just a form and they don't need to know what is happening behind the scenes. My problem is that the error_messages_for prefixes errors on associations with their name. I have a user model that has many addresses. When a user is signing up errors on address fields show up as Addresses first name can't be blank I would rather if it just said => First name can't be blank Now I can get this if I do the following => error_messages_for 'user', :object => [...@user.addresses] but then I don't get errors on the user object like => Password can't be blank Is there a way to tell the user object to drop errors it has on its associations so I can do the following => error_messages_for 'user', :object => [...@user, @user.addresses] At the moment it will result in the first name being flagged twice. # Addresses first name can't be blank # Password can't be blank # First name can't be blank --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Object has invalid ID after rollback
On Sep 25, 3:44 pm, Jeff wrote: > On Sep 25, 2:05 pm, Tony wrote: > > > > > I suspect there is a standard way to handle this issue but I haven't > > found it. > > > In my controller create action I have a Transaction. Lets say I'm > > creating a user object here. > > > def new > > User.transaction do > > @user = User.new(params[:user]) > > #do some stuff set success if no rollback > > end > > if success > > goto success page > > else > > render :action => :new > > end > > end > > > Now the problem here is when new is rendered @user has an id and it > > treats it as an edit instead of a new. > > That means you saved @user to the database, which you shouldn't be > doing in a new action. The create action is for saving to the > database. > I didn't save on the new action. The user did a create and after writing to the database there was an issue so I aborted the transaction and sent the user back to the new form (this is the standard practice when there is an error on create). My issue is that my objects now have bogus IDs in them causing the view to treat the object as created. To get around this I now recreate all my objects from the params and run valid? before rendering the new form so any errors will appear (I guess the save would have failed if there were errors on the objects themselves so calling valid is probably not needed). > Jeff > purpleworkshops.com > > > I could do a the following in the fail block > > @user = User.new(params[:user]) > > render :action => :new > > > but the errors are lost (and any changes or associations i created) > > > Or I could nil out the id > > @user.id = nil > > render :action => :new > > > It would be nice if the rollback did this for me (sort of like Object > > Transactions used to but without wiping out the errors and other > > information)? In my case User has many addresses and many orders so I > > also need to check and nil their IDs. yuck. > > > What's the best practice here? > > > Tony --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Authlogic - Render Partial
Paul - Just an update. Although changing the partial as you suggested allowed the "home" page to render properly, I think it also kept Authlogic from working properly. When the partial contains this: <% form_for UserSession.new :url => user_session_path do |f| %> I get nothing from Authlogic when I hit the Login button with no credentials entered. But when I revert to its original form: <% form_for @user_session, :url => user_session_path do |f| %> Authlogic gives me the following response: 1 error prohibited this user session from being saved There were problems with the following fields: * You did not provide any details for authentication. So here is how I was able to get it working: - Changed "home" controller as follows: def index @user_session = UserSession.new end - Changed view for "home" controller (i.e. - index.html.erb) as follows: <%= render :partial => "user_sessions/user_session", :locals => { :user_session => @user_session } %> This seems to work. Thanks for pointing me in the right direction. On Sep 25, 11:11 am, bui wrote: > pabcas - Thanks for responding to my question. I really appreciate > the help. Changing my partial to use "UserSession.new" seemed to > work. The "home" page was able to render properly. > > I checked the user_sessions_controller.rb file and I have this method > defined. > > def new > @user_session = UserSession.new > end > > Did you mean the home_controller.rb file? > > On Sep 25, 1:05 am, pabcas wrote: > > > Try <% form_for UserSession.new ... if you want the form to work > > anywhere, or make sure that @user_session is set in the controller, > > eg. @user_session = UserSession.new > > > Paul > > > On Sep 25, 6:54 am, bui wrote: > > > > The controller is the "home" controller and looks like this (very > > > basic): > > > > class HomeController < ApplicationController > > > def index > > > end > > > end > > > > The view for the home controller is is just a basic home page and I > > > just wanted to render a login partial there since I'm also planning to > > > use it elsewhere in the app. > > > > I assumed that there is no user_session, since a user is not logged in > > > at this point. So, I didn't think I would need to pass it anything. > > > I can hithttp://mysite/lgoinwithoutpassingany instance variables > > > and it shows the partial properly. > > > > Here's a trace: > > > > Showing app/views/user_sessions/_user_session.html.erb where line #1 > > > raised: > > > > Called id for nil, which would mistakenly be 4 -- if you really wanted > > > the id of nil, use object_id > > > > Extracted source (around line #1): > > > > 1: <% form_for @user_session, :url => user_session_path do |f| %> > > > 2: <%= f.error_messages %> > > > 3: <%= f.label :email %> > > > 4: <%= f.text_field :email %> > > > > Trace of template inclusion: app/views/home/index.html.erb > > > > RAILS_ROOT: c:/wwwroot/ror/blostm > > > Application Trace | Framework Trace | Full Trace > > > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/ > > > record_identifier.rb:76:in `dom_id' > > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/ > > > helpers/record_identification_helper.rb:16:in `dom_id' > > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/ > > > helpers/form_helper.rb:293:in `apply_form_for_options!' > > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/ > > > helpers/form_helper.rb:277:in `form_for' > > > c:/wwwroot/ror/mysite/app/views/user_sessions/_user_session.html.erb: > > > 1:in > > > `_run_erb_app47views47user_sessions47_user_session46html46erb_locals_object > > > _user_session' > > > c:/wwwroot/ror/mysite/app/views/home/index.html.erb:4:in > > > `_run_erb_app47views47home47index46html46erb' > > > > By the way, thanks for responding to my post. > > > > On Sep 24, 4:01 pm, pharrington wrote: > > > > > On Sep 24, 3:06 pm, bui wrote: > > > > > > New to Rails. Using Authlogic for authentication and went through > > > > > tutorial at github. Having a bit of a problem getting the login > > > > > screen to render as a partial from a different view file. > > > > > > I have a index.html.erb view file for the "home" controller. > > > > > > I tried <%= render :partial => "user_sessions/user_session" %> > > > > > > but it fails with this error: > > > > > > "Called id for nil, which would mistakenly be 4 -- if you really > > > > > wanted the id of nil, use object_id" > > > > > > user_sessions is the view directory for the login form created through > > > > > the Authlogic tutorial. I created a partial called > > > > > _user_session.html.erb which contains the entire login form and looks > > > > > like this: > > > > > > <% form_for @user_session, :url => user_session_path do |f| %> > > > > > <%= f.error_messages %> > > > > > <%= f.label :email %> > > > > > <%= f.text_field :email %> > > > > > > > > > > <%= f.label
[Rails] Ajax vs. Page Refresh
More of an opinion / discussion piece. When passing a lot of data, either via ajax, or simply refreshing the page and getting a lot of data back, is it better from a "amount of work placed on the server" perspective to do a full page refresh or to do an ajax refresh of parts of the page, data intensive or no? Thoughts? -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Drop down list ?
2009/9/25 Dudebot : > > Thanks again, Colin--in item.rb: > > belongs_to :category > > And in category.rb: > > has_many :items > > Item has a field category_id which I intended to populate with the > links from an item to its category. The field header in the category > db is where the name of the category is. > > Am I setting it up wrong then to have: > > <%= f.collection_select :category_id, Category.all, :id, :header, > {}, :multiple => false %> > > in the form? It does show up as a drop down box with the names > populated in it. > That should be fine as far as I can see, though I don't understand the extra [] in the html you showed. One question, you said that it is not saving the new category id value, are you sure that it is not saving it, or is it possibly just not displaying it when you come round next time. Have a look in the db to see. Another question, in an earlier post you showed the record being saved by update_attributes, what are you doing if that fails? In other words is the save succeeding? I am getting to the point where I don't know what is happening I am afraid. Colin --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Last call: Rails Training in Chicago on Oct. 24
Registration closes soon for "Rails for Everyone", a beginner's class to Ruby and the Rails framework. For those on this list that might not already be familiar with Purple Workshops, all of our public workshops are specifically geared for beginners, and we always aim for a very inclusive, non-intimidating, professional setting. If you've been wanting to start building professional websites with Rails and would like a fun way to get started, I hope you'll join us. Full workshop descriptions and registration here: http://www.purpleworkshops.com/ Thanks! Jeff --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Object has invalid ID after rollback
On Sep 25, 2:05 pm, Tony wrote: > I suspect there is a standard way to handle this issue but I haven't > found it. > > In my controller create action I have a Transaction. Lets say I'm > creating a user object here. > > def new > User.transaction do > @user = User.new(params[:user]) > #do some stuff set success if no rollback > end > if success > goto success page > else > render :action => :new > end > end > > Now the problem here is when new is rendered @user has an id and it > treats it as an edit instead of a new. That means you saved @user to the database, which you shouldn't be doing in a new action. The create action is for saving to the database. Jeff purpleworkshops.com > I could do a the following in the fail block > @user = User.new(params[:user]) > render :action => :new > > but the errors are lost (and any changes or associations i created) > > Or I could nil out the id > @user.id = nil > render :action => :new > > It would be nice if the rollback did this for me (sort of like Object > Transactions used to but without wiping out the errors and other > information)? In my case User has many addresses and many orders so I > also need to check and nil their IDs. yuck. > > What's the best practice here? > > Tony --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Invitation to connect on LinkedIn
LinkedIn Roger Pack requested to add you as a connection on LinkedIn: -- Mitin, I'd like to add you to my professional network on LinkedIn. - Roger Accept invitation from Roger Pack http://www.linkedin.com/e/uCUCiuukj5RrdSy7AOUCtG7bzcsR6bJYA2CKMuzkLjBRkPzzM2/blk/I353022527_3/6lColZJrmZznQNdhjRQnOpBtn9QfmhBt71BoSd1p65Lr6lOfPdvdP8Rcz8McPkPiiZdm6l7oz1njOYTcjkTe3kNdzsLrCBxbOYWrSlI/EML_comm_afe/ View invitation from Roger Pack http://www.linkedin.com/e/uCUCiuukj5RrdSy7AOUCtG7bzcsR6bJYA2CKMuzkLjBRkPzzM2/blk/I353022527_3/0PnPsOdj8Oc3cRcQALqnpPbOYWrSlI/svi/ -- DID YOU KNOW you can conduct a more credible and powerful reference check using LinkedIn? Enter the company name and years of employment or the prospective employee to find their colleagues that are also in your network. This provides you with a more balanced set of feedback to evaluate that new hire. http://www.linkedin.com/e/rsr/inv-27/ -- (c) 2009, LinkedIn Corporation --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Object has invalid ID after rollback
actually making the id nil doesn't work either. guess it still has created_at and updated_at items. Anyway. Is there a simple way to remedy this issue? On Sep 25, 3:05 pm, Tony wrote: > I suspect there is a standard way to handle this issue but I haven't > found it. > > In my controller create action I have a Transaction. Lets say I'm > creating a user object here. > > def new > User.transaction do > @user = User.new(params[:user]) > #do some stuff set success if no rollback > end > if success > goto success page > else > render :action => :new > end > end > > Now the problem here is when new is rendered @user has an id and it > treats it as an edit instead of a new. > > I could do a the following in the fail block > @user = User.new(params[:user]) > render :action => :new > > but the errors are lost (and any changes or associations i created) > > Or I could nil out the id > @user.id = nil > render :action => :new > > It would be nice if the rollback did this for me (sort of like Object > Transactions used to but without wiping out the errors and other > information)? In my case User has many addresses and many orders so I > also need to check and nil their IDs. yuck. > > What's the best practice here? > > Tony --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Object has invalid ID after rollback
I suspect there is a standard way to handle this issue but I haven't found it. In my controller create action I have a Transaction. Lets say I'm creating a user object here. def new User.transaction do @user = User.new(params[:user]) #do some stuff set success if no rollback end if success goto success page else render :action => :new end end Now the problem here is when new is rendered @user has an id and it treats it as an edit instead of a new. I could do a the following in the fail block @user = User.new(params[:user]) render :action => :new but the errors are lost (and any changes or associations i created) Or I could nil out the id @user.id = nil render :action => :new It would be nice if the rollback did this for me (sort of like Object Transactions used to but without wiping out the errors and other information)? In my case User has many addresses and many orders so I also need to check and nil their IDs. yuck. What's the best practice here? Tony --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: how to remove bogusetag by hpricot?
Haven't tried it, but you may want to look into the :fixup_tags option. --Matt Jones On Sep 25, 2:29 am, flyerhzm wrote: > I have use hpricot to translate users' input html. I want to remove > bogusetag as follows: > > >>doc = Hpricot " test world", :xhtml_strict => true > > =># " test world" {bogusetag } }>>>doc.to_s > > =>" test world" > > what I expected is "test world" without bogusetag , is it > possible? --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Drop down list ? I figured it out, but...
If I replace f.collection_select :category_id, Category.all, :id, :header, {}, :multiple => false with just f.collection_select :category_id, Category.all, :id, :header it works! Is this a bug, or is it me being an idiot? TIA, Craig On Sep 25, 11:59 am, Dudebot wrote: > Thanks again, Colin--in item.rb: > > belongs_to :category > > And in category.rb: > > has_many :items > > Item has a field category_id which I intended to populate with the > links from an item to its category. The field header in the category > db is where the name of the category is. > > Am I setting it up wrong then to have: > > <%= f.collection_select :category_id, Category.all, :id, :header, > {}, :multiple => false %> > > in the form? It does show up as a drop down box with the names > populated in it. > > Again, thanks super for helping me figure this out, > Craig > > On Sep 25, 8:19 am, Colin Law wrote: > > > > > 2009/9/25 Dudebot : > > > > Thanks super, Colin--that really helps. I believe category_id is > > > being passed, as in the development.log > > > > Processing ItemsController#update (for ::1 at 2009-09-25 06:34:23) > > > [PUT] > > > Parameters: {"commit"=>"Update", ... "id"=>"228", "item"=> > > > {..."category_id"=>["2"], ...}} > > > This looks a bit odd, why is it passing the id as a single element > > array I wonder? > > See below > > > > [4;35;1mPage Load (1.1ms) [0m [0mSELECT * FROM "pages" ORDER BY > > > position [0m > > > [4;36;1mUser Load (0.6ms) [0m [0;1mSELECT * FROM "users" WHERE > > > ("users"."id" = 1) LIMIT 1 [0m > > > [4;35;1mItem Load (0.7ms) [0m [0mSELECT * FROM "items" WHERE > > > ("items"."id" = 228) [0m > > > Redirected tohttp://localhost:3000/items/228 > > > Completed in 102ms (DB: 2) | 302 Found [http://localhost/items/228] > > > > and for different updates, the number in category_id [ ] is changing. > > > In my controller, I have the provided boilerplate for update: > > > > def update > > > �...@item = Item.find( params[ :id ] ) > > > > respond_to do |format| > > > if @item.update_attributes(params[:item]) > > > ... > > > > Am I missing something in the controller? Does a collection need to > > > be handled separately? > > > > Many TIA, > > > Craig > > > > On Sep 25, 2:36 am, Colin Law wrote: > > >> 2009/9/25 Dudebot : > > > >> > Hi Gurus, I'm trying to tackle a drop down list. I have category and > > >> > item dbs, and they're wired up with category has_many :items and item > > >> > belongs_to :category, and an item has a category_id. I have this code > > >> > in my new/edit.html.erb for item: > > > >> > <%= f.collection_select :category_id, > > >> > Category.find_main, :id, :header, {}, :multiple => false %> > > > I don't see anything wrong with this. > > > >> > And a pretty drop down list comes up, but no matter what I do, I can't > > >> > save an item with a different category--it always stubbornly records > > >> > the same one (or doesn't change it at all). The source html code > > >> > generated is: > > > >> > > > There is the problemI think, the extra set of [] for item[category_id]. > > Are you sure you have item belongs_to :category? It is as if it > > thinks there should be an array of id values. > > > Colin > > > >> > value="3">Awesome Things > > >> > Good Things > > >> > Better Things > > > >> > ...and although I can "choose" a different category for an item than > > >> > 'Good Things', it only records 'Good Things' (category_id 1) for all > > >> > items. > > > >> The first thing to do is to look in your log file (log/developent.log) > > >> to check that the selection is being passed in params. If it is then > > >> consider whether what the controller action that you are passing it to > > >> is doing with it. > > > >> Colin --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: how can I use Apache to serve static content for a RoR app when I have only .htaccess access (and can't add Apache modules) [on Dreamhost shared server]
Note that the X-Sendfile method in the linked article is only supported by an Apache module, which doesn't appear to be installed on the default DH config. So you're back where you started... I'd recommend contacting DH support - I've never worked with them, but the support at Site5 has always been willing to install gems / Apache modules that were standard. --Matt Jones On Sep 25, 1:53 pm, Greg Hauptmann wrote: > thanks Casey - you no doubt correct :) I'll run with your suggested > 'don't over-engineer' concept... > > 2009/9/25 daphonz : > > > > > > > > > Greg, > > > It sounds like you have a contradicting desire here. You say you want > > the uploads to be served directly by the Apache server (so you don't > > have Rails touching it), but you still want some form of > > authentication to make sure people can access it (which I imagine is > > what your Rails app is doing). > > > The overhead from processing a Rails request is quite minimal, > > especially is you're just doing some sort of user authentication and > > not some complex query/data gathering. My recommendation would be to > > use something like Paperclip (http://www.thoughtbot.com/projects/ > > paperclip) to help you upload files to your webserver, but protect > > access by serving the files through a Rails controller (something like > > this:http://www.therailsway.com/2009/2/22/file-downloads-done-right). > > > And again, if you're really, really concerned about your server > > overhead (like you'll be getting tens of thousands of requests per > > hour), you can always move some of this logic into Rails Metal to > > decrease the overhead, but, again, it's unlikely that you'll need to > > do so. > > > -Casey > > > On Sep 24, 4:52 pm, Greg Hauptmann > > wrote: > >> (bump - still really interested in response if someone is knowable in this > >> area) > > >> 2009/9/23 Greg Hauptmann : > > >> > Hi, > > >> > Are there any Rails/Apache guru's that might know if it's possible > >> > (and how) to have the ability for users to upload their content to my > >> > RoR application but then subsequent access to such static content > >> > would be: > > >> > a) served by APACHE web server [to avoid the overhead of going via > >> > Rails], but > >> > b) still want to have an authentication/authorisation check to > >> > occur before they can access the content > > >> > The constraint is I'm onhttp://dreamhost.com/sharedplatform where I > >> > have only access to the Apache .htaccess file and I can't add my own > >> > Apache modules. > > >> > http://wiki.dreamhost.com/Apache > >> > http://wiki.dreamhost.com/Htaccess > >> > http://wiki.dreamhost.com/KB_/_Unix_/_.htaccess_files > > >> > thanks > > >> -- > >> Greghttp://blog.gregnet.org/ > > -- > Greghttp://blog.gregnet.org/ --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: dynamic form problem
On Fri, Sep 25, 2009 at 9:29 AM, Jedrin wrote: > I don't suppose there is any easy way to tell what the focus was when > observe_form sends the call to the server ? Uh, the suggestion in my previous message? :-) -- Hassan Schroeder hassan.schroe...@gmail.com twitter: @hassan --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: How to ensure two tables reference the same record in a
Wow, so now I can do: class Component < ActiveRecord::Base # Make component.part a shortcut for component.lot.part def part(*args) lot.send :part, args end end ...and do things like: <%= mycomponent.part.number %> ...instead of ... <%= mycomponent.lot.part.number %> nice! --wpd --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Authlogic - Render Partial
pabcas - Thanks for responding to my question. I really appreciate the help. Changing my partial to use "UserSession.new" seemed to work. The "home" page was able to render properly. I checked the user_sessions_controller.rb file and I have this method defined. def new @user_session = UserSession.new end Did you mean the home_controller.rb file? On Sep 25, 1:05 am, pabcas wrote: > Try <% form_for UserSession.new ... if you want the form to work > anywhere, or make sure that @user_session is set in the controller, > eg. @user_session = UserSession.new > > Paul > > On Sep 25, 6:54 am, bui wrote: > > > The controller is the "home" controller and looks like this (very > > basic): > > > class HomeController < ApplicationController > > def index > > end > > end > > > The view for the home controller is is just a basic home page and I > > just wanted to render a login partial there since I'm also planning to > > use it elsewhere in the app. > > > I assumed that there is no user_session, since a user is not logged in > > at this point. So, I didn't think I would need to pass it anything. > > I can hithttp://mysite/lgoinwithoutpassing any instance variables > > and it shows the partial properly. > > > Here's a trace: > > > Showing app/views/user_sessions/_user_session.html.erb where line #1 > > raised: > > > Called id for nil, which would mistakenly be 4 -- if you really wanted > > the id of nil, use object_id > > > Extracted source (around line #1): > > > 1: <% form_for @user_session, :url => user_session_path do |f| %> > > 2: <%= f.error_messages %> > > 3: <%= f.label :email %> > > 4: <%= f.text_field :email %> > > > Trace of template inclusion: app/views/home/index.html.erb > > > RAILS_ROOT: c:/wwwroot/ror/blostm > > Application Trace | Framework Trace | Full Trace > > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/ > > record_identifier.rb:76:in `dom_id' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/ > > helpers/record_identification_helper.rb:16:in `dom_id' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/ > > helpers/form_helper.rb:293:in `apply_form_for_options!' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/ > > helpers/form_helper.rb:277:in `form_for' > > c:/wwwroot/ror/mysite/app/views/user_sessions/_user_session.html.erb: > > 1:in > > `_run_erb_app47views47user_sessions47_user_session46html46erb_locals_object > > _user_session' > > c:/wwwroot/ror/mysite/app/views/home/index.html.erb:4:in > > `_run_erb_app47views47home47index46html46erb' > > > By the way, thanks for responding to my post. > > > On Sep 24, 4:01 pm, pharrington wrote: > > > > On Sep 24, 3:06 pm, bui wrote: > > > > > New to Rails. Using Authlogic for authentication and went through > > > > tutorial at github. Having a bit of a problem getting the login > > > > screen to render as a partial from a different view file. > > > > > I have a index.html.erb view file for the "home" controller. > > > > > I tried <%= render :partial => "user_sessions/user_session" %> > > > > > but it fails with this error: > > > > > "Called id for nil, which would mistakenly be 4 -- if you really > > > > wanted the id of nil, use object_id" > > > > > user_sessions is the view directory for the login form created through > > > > the Authlogic tutorial. I created a partial called > > > > _user_session.html.erb which contains the entire login form and looks > > > > like this: > > > > > <% form_for @user_session, :url => user_session_path do |f| %> > > > > <%= f.error_messages %> > > > > <%= f.label :email %> > > > > <%= f.text_field :email %> > > > > > > > > <%= f.label :password %> > > > > <%= f.password_field :password %> > > > > > > > > <%= f.check_box :remember_me %><%= f.label :remember_me %> > > > > > > > > <%= image_submit_tag("/images/Login Button.jpg") %> > > > > <% end %> > > > > > user_sessions/new.html.erb now looks like this > > > > > <%= render :partial => 'user_session' %> > > > > > And this works: http://mysite/login (setup through a named route) > > > > And this works: http://mysite/user_sessions/new > > > > > However, trying this <%= render :partial => "user_sessions/ > > > > user_session" %> in the home/index.html.erb view fails. > > > > > Can anyone help with this? I seem to be missing something really > > > > fundamental here. > > > > > Thanks > > > > A guess, as I don't have the full backtrace and don't know what the > > > controller that passes to the view that calls the partial rendering > > > does: is the @user_session instance variable nil? --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http:/
[Rails] Re: How to ensure two tables reference the same record in a
On Fri, Sep 25, 2009 at 1:59 PM, Patrick Doyle wrote: > On Fri, Sep 25, 2009 at 1:55 PM, Marnen Laibow-Koser > wrote: >> Part has_many :components, :through => lots >> >> mypart.components >> >> Done! > > Light dawns on marble head. > > Of course! Sorry for the noise. oh yeah, and thanks! --wpd --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: How to ensure two tables reference the same record in a
On Fri, Sep 25, 2009 at 1:55 PM, Marnen Laibow-Koser wrote: > Part has_many :components, :through => lots > > mypart.components > > Done! Light dawns on marble head. Of course! Sorry for the noise. --wpd --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] cost model for a RoR where users could upload lots of file? what approach?
Hi, Any ideas/suggestions re what a good cost model / approach would be if one's Ruby on Rails application was to be successful, but noting users (as part of the service/application) could upload lots of files (images etc). What's a good way of have: (a) a simple cost model for use of the site, e.g. free up to X but costs Y after this per every Z, (b) noting files/images etc have to be protected by the rails authentication / authorization (c) makes sure I won't start losing money (e.g. if users have to pay less than the cost of storage / bandwidth) Any good ideas/approaches? Thanks --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: How to ensure two tables reference the same record in a
Patrick Doyle wrote: > class Part < ActiveRecord::Base > has_many :lots > has_many :components # or, maybe not > end > > class Lot < ActiveRecord::Base > belongs_to :part > has_many :components > end > > class Component < ActiveRecord::Base > belongs_to :part # or, maybe not > belongs_to :lot > end > > In my domain, a "lot" of "components" has a part number (which I > represent in RoR as a #belongs_to relationship, even though the term > "belongs_to" is somewhat misleading). Each component in the lot has a > part number which is the same as the part number for the entire lot Then the part number is a property of the lot, not the component. > > What is the best way to ensure that this consistency is maintained? > That is, that all parts in a lot reference the same part number as the > lot itself. Model the data correctly. Represent the part number once and only once, presumably in the lot. > > One way to ensure the consistency is to remove the "part_id" column > from the component table and to reference a components part number > through the lot association, i.e. mycomponent.lot.part.number. That is the correct way to do it. Repeating data in the database is always a sign that something is wrong with your schema. > The > problem is, sometimes I want to look at all of the parts that have a > given part number, and the only way I can see to do that is to collect > all of the lots with a given part number and then collect all of the > components in each of the lots, using something like: > mypart.lots.map(&:components).flatten. Part has_many :components, :through => lots mypart.components Done! [...] > --wpd Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: how can I use Apache to serve static content for a RoR app when I have only .htaccess access (and can't add Apache modules) [on Dreamhost shared server]
thanks Casey - you no doubt correct :) I'll run with your suggested 'don't over-engineer' concept... 2009/9/25 daphonz : > > Greg, > > It sounds like you have a contradicting desire here. You say you want > the uploads to be served directly by the Apache server (so you don't > have Rails touching it), but you still want some form of > authentication to make sure people can access it (which I imagine is > what your Rails app is doing). > > The overhead from processing a Rails request is quite minimal, > especially is you're just doing some sort of user authentication and > not some complex query/data gathering. My recommendation would be to > use something like Paperclip (http://www.thoughtbot.com/projects/ > paperclip) to help you upload files to your webserver, but protect > access by serving the files through a Rails controller (something like > this: http://www.therailsway.com/2009/2/22/file-downloads-done-right). > > And again, if you're really, really concerned about your server > overhead (like you'll be getting tens of thousands of requests per > hour), you can always move some of this logic into Rails Metal to > decrease the overhead, but, again, it's unlikely that you'll need to > do so. > > -Casey > > On Sep 24, 4:52 pm, Greg Hauptmann > wrote: >> (bump - still really interested in response if someone is knowable in this >> area) >> >> 2009/9/23 Greg Hauptmann : >> >> >> >> >> >> > Hi, >> >> > Are there any Rails/Apache guru's that might know if it's possible >> > (and how) to have the ability for users to upload their content to my >> > RoR application but then subsequent access to such static content >> > would be: >> >> > a) served by APACHE web server [to avoid the overhead of going via >> > Rails], but >> > b) still want to have an authentication/authorisation check to >> > occur before they can access the content >> >> > The constraint is I'm onhttp://dreamhost.com/shared platform where I >> > have only access to the Apache .htaccess file and I can't add my own >> > Apache modules. >> >> > http://wiki.dreamhost.com/Apache >> > http://wiki.dreamhost.com/Htaccess >> > http://wiki.dreamhost.com/KB_/_Unix_/_.htaccess_files >> >> > thanks >> >> -- >> Greghttp://blog.gregnet.org/ > > > > -- Greg http://blog.gregnet.org/ --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] How to ensure two tables reference the same record in a third table?
class Part < ActiveRecord::Base has_many :lots has_many :components # or, maybe not end class Lot < ActiveRecord::Base belongs_to :part has_many :components end class Component < ActiveRecord::Base belongs_to :part # or, maybe not belongs_to :lot end In my domain, a "lot" of "components" has a part number (which I represent in RoR as a #belongs_to relationship, even though the term "belongs_to" is somewhat misleading). Each component in the lot has a part number which is the same as the part number for the entire lot. What is the best way to ensure that this consistency is maintained? That is, that all parts in a lot reference the same part number as the lot itself. One way to ensure the consistency is to remove the "part_id" column from the component table and to reference a components part number through the lot association, i.e. mycomponent.lot.part.number. The problem is, sometimes I want to look at all of the parts that have a given part number, and the only way I can see to do that is to collect all of the lots with a given part number and then collect all of the components in each of the lots, using something like: mypart.lots.map(&:components).flatten. Unfortunately, that returns an array of components instead of the dynamic finder that would be returned by mypart.components. A second way to ensure the consistency is to add validations to the Lot and/or Component models. I could do that, but I have been advised elsewhere that validations are best when augmented by database constraints. (See http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/3b023e81df58619d, if you are interested). Is there some database agnostic way to add this sort of constraint? Or is there some other mechanism to implement this? --wpd --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Job Post - Ruby on Rails Jr Programmer/Tester - Austin, TX
Ruby on Rails Junior Programmer/Tester - OtherInbox OtherInbox is looking to hire an experienced Ruby On Rails Junior Programmer/Tester to join our team. We are looking for a highly motivated, goal-oriented individual who will be responsible for designing, building and maintaining sections of the product. The successful candidate should be a flexible, highly independent worker as well as an excellent team player, and able to work efficiently under tight deadlines. We're committed to being the best place for Ruby on Rails Programmers to work in Austin. Responsibilities • Write automated test routines and do manual testing • Deploy on Amazon Web Services including EC2, S3, SQS • Produce high quality, well-documented code in Ruby on Rails • Be part of a team and create a culture that attracts the best of the best • Use the product yourself and help make it better Requirements • 1+ year(s) Ruby On Rails programming experience OR extensive QA/ Testing experience with some knowledge of Ruby on Rails • Ability to work in an Agile, Scrum, XP environment • Good understanding of HTML, CSS and AJAX • Good understanding of Internet protocols such as TCP/IP, DNS, SMTP, HTTP, POP, IMAP, MIME • Good understanding of Web-based technology as it relates to the web- hosted model of software delivery • Hands-on experience working with a MySQL or SQL Server database, SQL programming • Excellent organization and communication skills • BS or equivalent experience About OtherInbox OtherInbox is an Austin-based start-up founded by serial entrepreneur and email-marketing guru Joshua Baer. OtherInbox is the cure for email overload - it provides consumers with a free email account that automatically organizes newsletters, social networking updates, coupons and receipts from online purchases so that its easy to find the most interesting things and ignore the rest. OtherInbox shows the consumer who is really responsible for sending them spam and gives them a powerful new Block button to stop it once and for all. To apply for this position Please send your resume to 50...@jobs.otherinbox.com. No phone calls, please. Please include the job title “Jr Programmer/Tester” in the subject line of your email. Local Austin candidates will be considered first. Once we’ve received and reviewed your resume we’ll contact you to solve a small programming challenge and then move you right into interviews. --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Authentication with Cookies instead of CookieStore Sessions
I would like to persist the user authentication between user sessions (basically a "remind me" by default). Sessions expire while cookies persist: why should I use a session for authentication and then another different cookie for the "remind me"? Can't I simply store a cookie whith a token and use it for both authentication and persistence? -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Moving to another database system
yaml_db is really quite handy! Thanks. One word of warning: as it uses Rails, it's not particularly fast. Not recommended if downtime is not a good idea. But, as far as making life easy for the admin.. Holy wow. -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Non blocking http request
Thanks for the info. delayed_job is a great piece but its just an overkill for what i wanted. I wanted something simple - not just from an implementation standpoint - but resource too (not add any extra load etc). "Keep in mind that each worker will check the database at least every 5 seconds." For those who are interested, a solution was to use ruby system ('...&'). I fire it off (and forget) and let the OS mange it. (If needed, you can also manage the queues via ruby Process) On Sep 24, 3:40 pm, "E. Litwin" wrote: > I agree with Tim on this. > > I am working on a new feature in one of my applications that entails > calling a long running process. > I wrote the application to do it synchronously at first to make sure > everything was working. > > Then I installed/setup delayed_job, modified my controller to call > @myobject.send_later :my_method and my call was now asynchronous. > > Total time to convert from synchronous to asynchronous: < 15 minutes. > > On Sep 24, 3:02 pm, Tim Lowrimore wrote: > > > Seriously, checkout delayed_job. It's super easy to implement, and is > > anything but overkill. Here's the URL for the > > project:http://github.com/collectiveidea/delayed_job > > > ... and as an added bonus, Ryan Bates covers it in a Railscast. Here's the > > URL for the Railscast: > > >http://railscasts.com/episodes/171-delayed-job > > > Cheers, > > Tim > > > On Thu, Sep 24, 2009 at 4:27 PM, nextpulse wrote: > > > > Any one know if it is possible to do a non-blocking http request > > > within Ror? > > > > I looked at Net::HTTP, nothing obvious. > > > > In my code, I want to fire off a http request (and not care about the > > > return or wait for it) and continue with the rest of the work. > > > I know I can use backgroundrb etc - but that seems an overkill. > > > > Any help appreciated. > > > > thanks. > > > -- > > Tim Lowrimore > > Coroutine LLC > > 516 Tennessee St., Suite 215 > > Memphis, TN 38103 > > office: 901.312.8818 > > mobile: 901.490.5325http://www.coroutine.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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Editing "Tutorials"
Then I get this error on the tutorial show page: edit_category_tutorial_url failed to generate from {:action=>"edit", :controller=>"tutorials", :category_id=>#}, expected: {:action=>"edit", :controller=>"tutorials"}, diff: {:category_id=>#} On Sep 25, 9:11 am, bill walton wrote: > Hi Joe, > > > > On Thu, 2009-09-24 at 22:54 -0700, Joe wrote: > > edit_category GET /categories/:id/edit(.:format) > > edit_category_tutorial GET /categories/:category_id/tutorials/:id/edit > > (.:format) > > > > On Sep 24, 11:09 am, Joe wrote: > > > > > <%= link_to 'Edit', edit_category_path(@category) %> > > > > > but when I change this to tutorials: > > > > > <%= link_to 'Edit', edit_tutorial_path(@tutorial) %> > > > > > I get this error on the tutorial show page: > > > > > undefined method `edit_tutorial_path' for # > > > 0x5ce52fc> > > It looks like you just need to use the correct route which, it appears, > is named: > > edit_category_tutorial_path > > HTH, > Bill --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Drop down list ?
Thanks again, Colin--in item.rb: belongs_to :category And in category.rb: has_many :items Item has a field category_id which I intended to populate with the links from an item to its category. The field header in the category db is where the name of the category is. Am I setting it up wrong then to have: <%= f.collection_select :category_id, Category.all, :id, :header, {}, :multiple => false %> in the form? It does show up as a drop down box with the names populated in it. Again, thanks super for helping me figure this out, Craig On Sep 25, 8:19 am, Colin Law wrote: > 2009/9/25 Dudebot : > > > > > Thanks super, Colin--that really helps. I believe category_id is > > being passed, as in the development.log > > > Processing ItemsController#update (for ::1 at 2009-09-25 06:34:23) > > [PUT] > > Parameters: {"commit"=>"Update", ... "id"=>"228", "item"=> > > {..."category_id"=>["2"], ...}} > > This looks a bit odd, why is it passing the id as a single element > array I wonder? > See below > > > > > > > [4;35;1mPage Load (1.1ms) [0m [0mSELECT * FROM "pages" ORDER BY > > position [0m > > [4;36;1mUser Load (0.6ms) [0m [0;1mSELECT * FROM "users" WHERE > > ("users"."id" = 1) LIMIT 1 [0m > > [4;35;1mItem Load (0.7ms) [0m [0mSELECT * FROM "items" WHERE > > ("items"."id" = 228) [0m > > Redirected tohttp://localhost:3000/items/228 > > Completed in 102ms (DB: 2) | 302 Found [http://localhost/items/228] > > > and for different updates, the number in category_id [ ] is changing. > > In my controller, I have the provided boilerplate for update: > > > def update > > �...@item = Item.find( params[ :id ] ) > > > respond_to do |format| > > if @item.update_attributes(params[:item]) > > ... > > > Am I missing something in the controller? Does a collection need to > > be handled separately? > > > Many TIA, > > Craig > > > On Sep 25, 2:36 am, Colin Law wrote: > >> 2009/9/25 Dudebot : > > >> > Hi Gurus, I'm trying to tackle a drop down list. I have category and > >> > item dbs, and they're wired up with category has_many :items and item > >> > belongs_to :category, and an item has a category_id. I have this code > >> > in my new/edit.html.erb for item: > > >> > <%= f.collection_select :category_id, > >> > Category.find_main, :id, :header, {}, :multiple => false %> > > I don't see anything wrong with this. > > > > >> > And a pretty drop down list comes up, but no matter what I do, I can't > >> > save an item with a different category--it always stubbornly records > >> > the same one (or doesn't change it at all). The source html code > >> > generated is: > > >> > > There is the problemI think, the extra set of [] for item[category_id]. > Are you sure you have item belongs_to :category? It is as if it > thinks there should be an array of id values. > > Colin > > > > >> > value="3">Awesome Things > >> > Good Things > >> > Better Things > > >> > ...and although I can "choose" a different category for an item than > >> > 'Good Things', it only records 'Good Things' (category_id 1) for all > >> > items. > > >> The first thing to do is to look in your log file (log/developent.log) > >> to check that the selection is being passed in params. If it is then > >> consider whether what the controller action that you are passing it to > >> is doing with it. > > >> Colin --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: dynamic form problem
That seems to work, thanks alot, things are looking a little better now. I don't suppose there is any easy way to tell what the focus was when observe_form sends the call to the server ? Right now I just keep the fields in a session and see which one changed, which is sort of a hack and prone to slight errors etc . On Sep 25, 11:53 am, bill walton wrote: > Hi Jedrin, > > On Fri, 2009-09-25 at 08:04 -0700, Jedrin wrote: > > Is there a way to focus through RJS ? > > page['element_id'].focus() > > Best regards, > Bill --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Question about classes in Rails
Let me start by stating the fact that I consider myself a ruby / rails novice (above newb, just enought to be dangerous, perhaps ... :) ) I have an issue that relates to the ruby-openx gem, which allows ruby to talk to an OpenX ad-server via XMLRPC, However, I think my problem is kind of a more basic problem related to Rails, but I am sure it is also probably due to the way that certain things are implemented in the gem, so I'm hopeful I can get some basic guidance here on a problem that has me stumped. OpenX::Services::Base has a section of code that the other modules / classes in the openx gem use when they extend this base class to retrieve the connection to the OpenX server that looks like this: @@connection= nil ... def connection= c @@connection = c end def connection unless @@connection and @@connection.id @@connection = Session.new(configuration['url']) @@connection.create( configuration['username'], configuration['password'] ) end @@connection end The connection is saved as a class variable, and evidently in Rails, at least in production mode or when config.cache_classes = true, classes appear to persist past an initial request so they don't have to be reloaded on every request. The OpenX XMLRPC API expects authenticated sessions to pass back a session id that is retrieved when you successfully login via the XMLRPC API. The OpenX::Services::Session class handles this just fine. However, what ends up happening is that the session times out due to lack of activity, and the XMLRPC API does not provide a way to tell if a session is expired or not, so it typically causes 500 internal server errors in the Rails app that's trying to communicate with OpenX. What I would like to do is basically have a private copy of the openx classes that exists only during a rails request and do not persist past the end of the request, independent of the config.cache_classes setting. I believe this would solve the problem well enough for me to be able to use as a work-around. Is it possible to do in Rails what I am asking? I think the reason this is not an issue with the library as written is that it was not written with Rails usage in mind, but for usage with either a cron job or a CLI ruby script instead; however, I have a need for it to operate properly in a Rails environment. I'm not keen on either re-writing the gem code, nor am I interested in keeping the session alive via a cron job, as that's a hack IMO, and not a solution. So, if anyone has any thoughts, I'd love to hear them. Thanks. The gem's code can be found at http://github.com/aasmith/openx, for anyone who is curious. --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] how to time out a query
Hi, I've got an activerecord query which takes longer than 100 seconds. I'm using rails 2.2 with postgresql 8.3. http://www.postgresql.org/docs/8.3/static/runtime-config-client.html mentions an option called "statement_timeout" which when set aborts a query which takes longer than x milli seconds. How do I pass this option to AR so that it in turn passes this to postgresql? cheers, skar. -- -- The life so short, the craft so long to learn. --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: how can I use Apache to serve static content for a RoR app when I have only .htaccess access (and can't add Apache modules) [on Dreamhost shared server]
Greg, It sounds like you have a contradicting desire here. You say you want the uploads to be served directly by the Apache server (so you don't have Rails touching it), but you still want some form of authentication to make sure people can access it (which I imagine is what your Rails app is doing). The overhead from processing a Rails request is quite minimal, especially is you're just doing some sort of user authentication and not some complex query/data gathering. My recommendation would be to use something like Paperclip (http://www.thoughtbot.com/projects/ paperclip) to help you upload files to your webserver, but protect access by serving the files through a Rails controller (something like this: http://www.therailsway.com/2009/2/22/file-downloads-done-right). And again, if you're really, really concerned about your server overhead (like you'll be getting tens of thousands of requests per hour), you can always move some of this logic into Rails Metal to decrease the overhead, but, again, it's unlikely that you'll need to do so. -Casey On Sep 24, 4:52 pm, Greg Hauptmann wrote: > (bump - still really interested in response if someone is knowable in this > area) > > 2009/9/23 Greg Hauptmann : > > > > > > > Hi, > > > Are there any Rails/Apache guru's that might know if it's possible > > (and how) to have the ability for users to upload their content to my > > RoR application but then subsequent access to such static content > > would be: > > > a) served by APACHE web server [to avoid the overhead of going via > > Rails], but > > b) still want to have an authentication/authorisation check to > > occur before they can access the content > > > The constraint is I'm onhttp://dreamhost.com/shared platform where I > > have only access to the Apache .htaccess file and I can't add my own > > Apache modules. > > > http://wiki.dreamhost.com/Apache > > http://wiki.dreamhost.com/Htaccess > > http://wiki.dreamhost.com/KB_/_Unix_/_.htaccess_files > > > thanks > > -- > Greghttp://blog.gregnet.org/ --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] I have a problem with scaffolds
Hi there I have created some scaffolds, but they dont work for example = $ script/generate scaffold Posts title:string body:text /usr/lib/ruby/1.8/xmlsimple.rb:275: warning: already initialized constant KNOWN_OPTIONS /usr/lib/ruby/1.8/xmlsimple.rb:280: warning: already initialized constant DEF_KEY_ATTRIBUTES /usr/lib/ruby/1.8/xmlsimple.rb:281: warning: already initialized constant DEF_ROOT_NAME /usr/lib/ruby/1.8/xmlsimple.rb:282: warning: already initialized constant DEF_CONTENT_KEY /usr/lib/ruby/1.8/xmlsimple.rb:283: warning: already initialized constant DEF_XML_DECLARATION /usr/lib/ruby/1.8/xmlsimple.rb:284: warning: already initialized constant DEF_ANONYMOUS_TAG /usr/lib/ruby/1.8/xmlsimple.rb:285: warning: already initialized constant DEF_FORCE_ARRAY /usr/lib/ruby/1.8/xmlsimple.rb:286: warning: already initialized constant DEF_INDENTATION /usr/lib/ruby/1.8/xmlsimple.rb:287: warning: already initialized constant DEF_KEY_TO_SYMBOL :0:Warning: Gem::SourceIndex#search support for Regexp patterns is deprecated exists app/models/ exists app/controllers/ exists app/helpers/ create app/views/posts exists app/views/layouts/ exists test/functional/ exists test/unit/ exists public/stylesheets/ create app/views/posts/index.html.erb create app/views/posts/show.html.erb create app/views/posts/new.html.erb create app/views/posts/edit.html.erb identical app/views/layouts/posts.html.erb identical public/stylesheets/scaffold.css create app/controllers/posts_controller.rb create test/functional/posts_controller_test.rb create app/helpers/posts_helper.rb route map.resources :posts dependency model :0:Warning: Gem::SourceIndex#search support for Regexp patterns is deprecated existsapp/models/ existstest/unit/ existstest/fixtures/ createapp/models/posts.rb createtest/unit/posts_test.rb createtest/fixtures/posts.yml existsdb/migrate createdb/migrate/20090925154641_create_posts.rb $ rm db/development.sqlite3 db/schema.rb $ rake db:migrate = the result is OK... Also I have even I have striped in routes.rb to (also let the default content) ActionController::Routing::Routes.draw do |map| map.resources :posts end But the result is the same : == NameError in Posts#index Showing posts/index.html.erb where line #22 raised: undefined local variable or method `new_posts_path' for # Extracted source (around line #22): 19: 20: 21: 22: <%= link_to 'New posts', new_posts_path %> RAILS_ROOT: /media/desa/smartdsign/svn/catalogo Application Trace | Framework Trace | Full Trace app/views/posts/index.html.erb:22:in `_run_erb_47app47views47posts47index46html46erb' app/controllers/posts_controller.rb:7:in `index' vendor/rails/actionpack/lib/action_view/base.rb:338:in `send' vendor/rails/actionpack/lib/action_view/base.rb:338:in `execute' vendor/rails/actionpack/lib/action_view/template_handlers/ compilable.rb:29:in `send' vendor/rails/actionpack/lib/action_view/template_handlers/ compilable.rb:29:in `render' vendor/rails/actionpack/lib/action_view/template.rb:35:in `render' vendor/rails/actionpack/lib/action_view/template.rb:22:in `render_template' vendor/rails/actionpack/lib/action_view/base.rb:245:in `render_file' vendor/rails/actionpack/lib/action_controller/base.rb:1108:in `render_for_file' vendor/rails/actionpack/lib/action_controller/base.rb:865:in `render_with_no_layout' vendor/rails/actionpack/lib/action_controller/base.rb:880:in `render_with_no_layout' vendor/rails/actionpack/lib/action_controller/layout.rb:251:in `render_without_benchmark' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render' vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb: 8:in `realtime' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render' vendor/rails/actionpack/lib/action_controller/mime_responds.rb:131:in `send' vendor/rails/actionpack/lib/action_controller/mime_responds.rb:131:in `custom' vendor/rails/actionpack/lib/action_controller/mime_responds.rb:160:in `call' vendor/rails/actionpack/lib/action_controller/mime_responds.rb:160:in `respond' vendor/rails/actionpack/lib/action_controller/mime_responds.rb:154:in `each' vendor/rails/actionpack/lib/action_controller/mime_responds.rb:154:in `respond' vendor/rails/actionpack/lib/action_controller/mime_responds.rb:107:in `respond_to' vendor/rails/actionpack/lib/action_controller/base.rb:1162:in `send' vendor/rails/actionpack/lib/action_controller/base.rb:1162:in `perform_action_without_filters' vendor/rails/actionpack/lib/action_controller/filters.rb:580:in `call_filters' vendor/rails/actionpack/lib/action_controller/filters.rb:573:in `perform_action_without
[Rails] Re: named_scope, sql-view.
Colin, Fred, Thank you. Colin, it is not a typo, as I am learning ruby+rails I read that rails is expecting the plural of the name of the table. I went nuts changing the names of the tables. At the time I did not know that I could force the names, on top of this this Spanish language influenced the person who designed the DB and rails is English oriented ;-) I believe that inside :select you need the name of the table, and the symbol of the association is not allowed. Of course, I maybe wrong but I have not yet seen a sample code that lead me to think otherwise. class Estado < ActiveRecord::Base has_many :masters end class Master < ActiveRecord::Base belongs_to :estado belongs_to :municipio belongs_to :localidade has_one :migrante1 has_one :migrante2 has_one :migrante3 has_one :migrante4 ## ##named_scope ## named_scope :masculino, :conditions => {:sexo=>'masculino'} named_scope :femenino, :conditions => {:sexo=>'femenino'} ## Test named_scope :edo, :joins=>:estado, :select=>"estados.estado" end Let me mention that this database is a legacy from one of the previous project/team (political scie...@tuffs University). I did check the attributes, from the console: >> ma=Master.edo => ma.first.attributes => {"estado"=>"Michoacan"} This is progress, but what is the syntax to access it? or this is it, and I have to treat it as a hash from this point on? Although, not what I am looking for but related, http://snippets.dzone.com/posts/show/2089 > The default output from inspect never shows columns from joined > tables, but they are still there. (take a peak at the attributes for > one of the objects returned in this manner) > > Fred -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: dynamic form problem
Hi Jedrin, On Fri, 2009-09-25 at 08:04 -0700, Jedrin wrote: > Is there a way to focus through RJS ? page['element_id'].focus() Best regards, Bill --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: dynamic form problem
Since I rerender the form using ajax, I am not sure if document.myform.myfield.focus() will work and I have not had any luck. Is there a way to focus through RJS ? The best approach I can think of is to get rid of the form and have a field observer for each field, save the values in a session and when the user clicks the save button, I treat it as if it was a form submit. I'm not so much of a web expert on these kinds of things and I end up doing whatever I can make sense of if I can't find a decent example someplace .. On Sep 24, 6:03 pm, Hassan Schroeder wrote: > On Thu, Sep 24, 2009 at 2:11 PM, Jedrin wrote: > > Actually, the problem with re rendering the form and setting the > > focus is knowing what the focus was before observe_form sent the > > request to the server. The most obvious hack way is to keep the form > > values in a session and see which one changed since the last time. > > I'd think the most obvious would be to have each focus() event save > the target element's id to a single global variable, and use that value > to reset the focus afterwards. > > Just a thought. > -- > Hassan Schroeder hassan.schroe...@gmail.com > twitter: @hassan --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Non-ActiveRecord based model being passed as string?
Ilan Berci wrote: > The method I provided is not maintainable as adding attributes to the > class will break the 'serialization' mechanism.. a much better solution > would be to use reflection to run through your attributes and map them > (which is slightly different in 1.9 as compared to 1.8) > > ilan How would this be done, in a very basic way, when this table is not backed by ActiveRecord? The reflection class is provided by ActiveRecord and this is a table-less data structure right now. Hence the weird need to pass stuff around. I would put it in the db, but this is data being pulled from a database and remapped in a way, as we're using a non-rails mapped oracle db. My app has to tie into existing data, so its a bit of a problem. Thanks for all the help so far. -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Rails tiny plugin using jquery, paerclip with image upload and media upload support
Rails tiny plugin using jquery, paerclip with image upload and media upload support http://github.com/sandipransing/rails_tiny_mce Sandip -- Ruby on Rails Developer http://funonrails.wordpress.com www.joshsoftware.com http://brandpotion.com (Latest project released) --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Drop down list ?
2009/9/25 Dudebot : > > Thanks super, Colin--that really helps. I believe category_id is > being passed, as in the development.log > > Processing ItemsController#update (for ::1 at 2009-09-25 06:34:23) > [PUT] > Parameters: {"commit"=>"Update", ... "id"=>"228", "item"=> > {..."category_id"=>["2"], ...}} This looks a bit odd, why is it passing the id as a single element array I wonder? See below > [4;35;1mPage Load (1.1ms) [0m [0mSELECT * FROM "pages" ORDER BY > position [0m > [4;36;1mUser Load (0.6ms) [0m [0;1mSELECT * FROM "users" WHERE > ("users"."id" = 1) LIMIT 1 [0m > [4;35;1mItem Load (0.7ms) [0m [0mSELECT * FROM "items" WHERE > ("items"."id" = 228) [0m > Redirected to http://localhost:3000/items/228 > Completed in 102ms (DB: 2) | 302 Found [http://localhost/items/228] > > and for different updates, the number in category_id [ ] is changing. > In my controller, I have the provided boilerplate for update: > > def update > �...@item = Item.find( params[ :id ] ) > > respond_to do |format| > if @item.update_attributes(params[:item]) > ... > > Am I missing something in the controller? Does a collection need to > be handled separately? > > Many TIA, > Craig > > On Sep 25, 2:36 am, Colin Law wrote: >> 2009/9/25 Dudebot : >> >> >> >> >> >> >> >> > Hi Gurus, I'm trying to tackle a drop down list. I have category and >> > item dbs, and they're wired up with category has_many :items and item >> > belongs_to :category, and an item has a category_id. I have this code >> > in my new/edit.html.erb for item: >> >> > <%= f.collection_select :category_id, >> > Category.find_main, :id, :header, {}, :multiple => false %> I don't see anything wrong with this. >> >> > And a pretty drop down list comes up, but no matter what I do, I can't >> > save an item with a different category--it always stubbornly records >> > the same one (or doesn't change it at all). The source html code >> > generated is: >> >> > > > value="3">Awesome Things >> > Good Things >> > Better Things >> >> > ...and although I can "choose" a different category for an item than >> > 'Good Things', it only records 'Good Things' (category_id 1) for all >> > items. >> >> The first thing to do is to look in your log file (log/developent.log) >> to check that the selection is being passed in params. If it is then >> consider whether what the controller action that you are passing it to >> is doing with it. >> >> Colin > > > --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Parameter passing problem ..
Thank god Resolved .. After getting rid of all these errors.. This is working fine .. Thanks a lot to you guyz .. :) > Are you sure it is in the code? I see it is in the code you posted > earlier, are you sure it is still there? If so then play about with > the source code a bit in that area to work out what is happening. > Don't worry about whether it is valid html for the moment just try to > work out why the html does not line up with the source. Maybe put > some extra characters in the area where the " ) is and see what > happens. Alternatively remove bits of you code (some of the bits > inside the " " till it starts working. It is difficult to see why the > ] is there but not the ) which is why I wonder if the code has been > accidentally changed. > > Colin -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Object#type is deprecated; use Object#class
On Sep 25, 2009, at 7:57 AM, Srikanth Jeeva wrote: > I have got the same error! > > I have used this: > >>> u = User.find 1 >>> u.type > (irb):21: warning: Object#type is deprecated; use Object#class >>> u.class.name > => "Admin" > > so i have used "u.class.name" instead u.type > > Thanks, > Srikanth J > > http://srikanthjeeva.blogspot.com > If you really have a database column called "type", then you should be using Single-Table Inheritance (because ActiveRecord is going to make that assumption). You can change the column that AR expects to use to a name different than 'type' (look it up) or you can reference u['type'] or u[:type] rather than u.type to avoid the warning. -Rob Rob Biedenharn http://agileconsultingllc.com r...@agileconsultingllc.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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Categories and articles plug-in, act_as_tree, act_as_list
2009/9/25 rtacconi : > > Thanks for your help. > > On Sep 25, 9:44 am, Colin Law wrote: >> 2009/9/25 rtacconi : >> >> >> >> > This is my first message, so hello to everybody! >> >> > I would like to have a simple intranet with categories and articles >> > management. I think to use act_as_tree for the categories and >> > act_as_list for the articles, but any article should be connected to >> > one category. So in any category I can have one or more articles in a >> > list. Do I have to declare a Category class as parent of the list of >> > the articles? As you might guess I am a Ruby and Rails rookie. >> >> > I would like to know if there is a plug-in with this features, where I >> > can manage categories and articles. >> >> Apologies if you have already done this but I recommend newcommers to >> look at the rails guides athttp://guides.rubyonrails.org/ >> particularly Getting Started and ActiveRecord Associations. These may >> answer some of your questions. >> > I had a look and I wll start soon to read migrations and ActiveRecord > chapters in "Agile Web Development in Rails" >> Are you sure you need a _list_ of articles as opposed to just a >> collection of them such as would be provided by the normal has_many, >> belongs_to relationship? > > Let's say you have some articles and the administrator wants to order > the articles display. Showing the articles using act_as_list is > perfect, since I want to show the articles as and ordered list. If the articles have a definite intrinsic sequence that is not determined by date or other property of the article then acts_as_list may indeed be appropriate. Note that acts_as_list is about how the data is stored in the database rather than just an order of viewing at some instant. Colin --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: looking for .rhml.r488 instead .rhtml page
Abhinav Saxena wrote: > Will renaming the files from rhtml to html.erb help ? > > Thanks, > Abhinav > > -- > http://twitter.com/abhinav > > > > On Fri, Sep 25, 2009 at 5:05 PM, Priya Saini < wat i did is, i changed the action from list to list2 and the corresponding file from list.rhtml to list2.rhtml and it worked fine.. Looks as if Rails 2.3.2 is not liking the name 'list' :P -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: calling partials from a layout - once nil, once not nil
Michal Burak wrote: > > home/_current_user.pl.html.erb : > <% if current_user %> > NOT NIL > <% else %> > NIL > <% end %> > > home/_user_box.pl.html.erb : > <% if current_user %> > NOT NIL > <% else %> > NIL > <% end %> > > layouts/layout.html.erb : > <%= render :partial => '/home/current_user' -%> > <%= render :partial => '/home/user_box' %> > > > Why is that so? Why one time it is nil and the other time it is not nil? > > Any help appreciated. > > Regards. It has to do with the name of the partial, Rails does some magic by looking at the name of the partial and then making a local variable (with the same name as the partial) accessible to that partial. i.e. a partial entitled "_current_user" will have current_user as a local whereas a partial entitled "_user_box" will have user_box as a local. This was new functionality introduced with rails 2 I believe.. Don't forget that the render() can have :object and :locals passed into it.. hth ilan -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Non-ActiveRecord based model being passed as string?
Luke van der Hoeven wrote: > what does the constructor method do differently in 1.8 vs. 1.9? Does it > exist in 1.8 or 1.9? Currently working with 1.8.x so I'm not sure my > constructors will be able to do it without that extra code. > It wasnt' the initialize() method that I didn't like, it was the to_params() non-dry hack which made me feel a little ill.. The method I provided is not maintainable as adding attributes to the class will break the 'serialization' mechanism.. a much better solution would be to use reflection to run through your attributes and map them (which is slightly different in 1.9 as compared to 1.8) ilan -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: looking for .rhml.r488 instead .rhtml page
Will renaming the files from rhtml to html.erb help ? Thanks, Abhinav -- http://twitter.com/abhinav On Fri, Sep 25, 2009 at 5:05 PM, Priya Saini < rails-mailing-l...@andreas-s.net> wrote: > > Salil Gaikwad wrote: > > Ok. > > Try following links may be that helps you, > > http://www.ruby-forum.com/topic/80494 > > http://railsruby.blogspot.com/2006/02/errnoenoent-when-opening-url.html > > http://forum.slicehost.com/comments.php?DiscussionID=1076 > > http://mail.python.org/pipermail/python-list/2003-May/204168.html > > > > > > Thanks, > > > > Salil Gaikwad > > Thanks Salil: > > Bt no help .. the main issue is why is it looking for list.rhtml.r488 > instead of list.rhtml.. I use SVN to manage my projects bt there exist > no such extra file or something > -- > 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Paperclip: Adding attachment to model on update not working
Hi, This is a bit of a special case. Ive got a POST form for a posts model which has a preview functionality. So if the user clicks on "Preview", then the model is saved and a new window opens with the preview. And the user can keep adding content to the post and previewing before he's satisfied and clicks on "Publish". And for every subsequent previews, i pull that original model from the DB and update it with the new attributes. So when the user enters some information but does not upload an attachment the first time, and then clicks "Preview", the preview works fine and a record is created in the DB. Now, if he adds an attachment and hits "Preview", the record is pulled from the DB and update_attributes is done on it. But paperclip throws an "ActionController::RoutingError (No route matches ..." error and the attachment is not uploaded. I think, its looking for the original attachment that has to be updated. How can I get around this issue? Any ideas? Thanks! --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Object#type is deprecated; use Object#class
I have got the same error! I have used this: >> u = User.find 1 >> u.type (irb):21: warning: Object#type is deprecated; use Object#class >> u.class.name => "Admin" so i have used "u.class.name" instead u.type Thanks, Srikanth J http://srikanthjeeva.blogspot.com -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Widgets
Have a look at browsercms in rails Sandip On Wed, Sep 23, 2009 at 5:17 PM, Smit Shah wrote: > > Hi All, > > Any one is having any idea about how to create widgets in rails??? > > Thanks in advance... > -- > Posted via http://www.ruby-forum.com/. > > > > -- Ruby on Rails Developer http://funonrails.wordpress.com www.joshsoftware.com http://brandpotion.com (Latest project released) --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] memcache-client error though i have memcache-client gem installed
Hi My application was using rails 2.1.0 that i changed to rails 2.3.3 then i did rake rails:update. while script/server start it gives me error memcache-client error. Sandip -- Ruby on Rails Developer http://funonrails.wordpress.com www.joshsoftware.com http://brandpotion.com (Latest project released) --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Getting the server port number during initialization
On Fri, 2009-09-25 at 04:40 -0700, johnr wrote: > Thanks for saying just enough. You're welcome. Glad it helped. Best regards, Bill --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] calling partials from a layout - once nil, once not nil
Hi, Rails 2.3.3 + restful_authentication. current_user is a method from lib/authenticated_system.rb through "include AuthenticatedSystem" in application_controller.rb home/_current_user.pl.html.erb : <% if current_user %> NOT NIL <% else %> NIL <% end %> home/_user_box.pl.html.erb : <% if current_user %> NOT NIL <% else %> NIL <% end %> layouts/layout.html.erb : <%= render :partial => '/home/current_user' -%> <%= render :partial => '/home/user_box' %> - OUTPUT: --- NIL NOT NIL LOGS: --- [INFO : 0925 13:43:58 #9238] Rendering template within layouts/layout [INFO : 0925 13:43:58 #9238] Rendering home/index [DEBUG: 0925 13:43:58 #9238] Rendered home/_current_user.pl (0.2ms) [DEBUG: 0925 13:43:58 #9238] User Columns (1.9ms) SHOW FIELDS FROM `users` [DEBUG: 0925 13:43:58 #9238] User Load (0.2ms) SELECT * FROM `users` WHERE (`users`.`id` = 1) LIMIT 1 [DEBUG: 0925 13:43:58 #9238] Rendered home/_user_box.pl (6.9ms) [INFO : 0925 13:43:58 #9238] Completed in 16ms (View: 8, DB: 2) | 200 OK [http://localhost/] Why is that so? Why one time it is nil and the other time it is not nil? Any help appreciated. Regards. -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Drop down list ?
Thanks super, Colin--that really helps. I believe category_id is being passed, as in the development.log Processing ItemsController#update (for ::1 at 2009-09-25 06:34:23) [PUT] Parameters: {"commit"=>"Update", ... "id"=>"228", "item"=> {..."category_id"=>["2"], ...}} [4;35;1mPage Load (1.1ms) [0m[0mSELECT * FROM "pages" ORDER BY position [0m [4;36;1mUser Load (0.6ms) [0m[0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) LIMIT 1 [0m [4;35;1mItem Load (0.7ms) [0m[0mSELECT * FROM "items" WHERE ("items"."id" = 228) [0m Redirected to http://localhost:3000/items/228 Completed in 102ms (DB: 2) | 302 Found [http://localhost/items/228] and for different updates, the number in category_id [ ] is changing. In my controller, I have the provided boilerplate for update: def update @item = Item.find( params[ :id ] ) respond_to do |format| if @item.update_attributes(params[:item]) ... Am I missing something in the controller? Does a collection need to be handled separately? Many TIA, Craig On Sep 25, 2:36 am, Colin Law wrote: > 2009/9/25 Dudebot : > > > > > > > > > Hi Gurus, I'm trying to tackle a drop down list. I have category and > > item dbs, and they're wired up with category has_many :items and item > > belongs_to :category, and an item has a category_id. I have this code > > in my new/edit.html.erb for item: > > > <%= f.collection_select :category_id, > > Category.find_main, :id, :header, {}, :multiple => false %> > > > And a pretty drop down list comes up, but no matter what I do, I can't > > save an item with a different category--it always stubbornly records > > the same one (or doesn't change it at all). The source html code > > generated is: > > > > value="3">Awesome Things > > Good Things > > Better Things > > > ...and although I can "choose" a different category for an item than > > 'Good Things', it only records 'Good Things' (category_id 1) for all > > items. > > The first thing to do is to look in your log file (log/developent.log) > to check that the selection is being passed in params. If it is then > consider whether what the controller action that you are passing it to > is doing with it. > > Colin --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Getting the server port number during initialization
I have one admin-like server that provides information that is used across a suite of other servers that provide various client-facing services. In order to synchronize changes to ... As I was typing, I realized that I was approaching the problem from the wrong direction. Instead of providing the address from the client- facing server, the admin-like server could get the address from the request. Thanks for saying just enough. On Sep 25, 4:18 am, bill walton wrote: > Hi John, > > On Thu, 2009-09-24 at 10:22 -0700, johnr wrote: > > In the environment.rb I need to use the port number that the server is > > being started under in an after_initialize block in order to register > > my server with another server. I've looked in config > > (Rails:Configuration) and ENV, but It doesn't look to be there. I know > > that a workaround would be to set a PORT environment variable and use > > that on the command line, for example. But I would rather use an > > already existent method. > > On a request-by-request basis you can test request.host_with_port. But, > AFAIK, Rails is unaware of the port used by the web server until that > server makes a request. If it were otherwise, it would be difficult to > run a pack of mongrels in front of the app. Perhaps if you said more > about what you mean by 'register my server with another server', we > could be more help. > > HTH, > Bill --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: looking for .rhml.r488 instead .rhtml page
Salil Gaikwad wrote: > Ok. > Try following links may be that helps you, > http://www.ruby-forum.com/topic/80494 > http://railsruby.blogspot.com/2006/02/errnoenoent-when-opening-url.html > http://forum.slicehost.com/comments.php?DiscussionID=1076 > http://mail.python.org/pipermail/python-list/2003-May/204168.html > > > Thanks, > > Salil Gaikwad Thanks Salil: Bt no help .. the main issue is why is it looking for list.rhtml.r488 instead of list.rhtml.. I use SVN to manage my projects bt there exist no such extra file or something -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: looking for .rhml.r488 instead .rhtml page
Ok. Try following links may be that helps you, http://www.ruby-forum.com/topic/80494 http://railsruby.blogspot.com/2006/02/errnoenoent-when-opening-url.html http://forum.slicehost.com/comments.php?DiscussionID=1076 http://mail.python.org/pipermail/python-list/2003-May/204168.html Thanks, Salil Gaikwad -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Categories and articles plug-in, act_as_tree, act_as_list
Thanks for your help. On Sep 25, 9:44 am, Colin Law wrote: > 2009/9/25 rtacconi : > > > > > This is my first message, so hello to everybody! > > > I would like to have a simple intranet with categories and articles > > management. I think to use act_as_tree for the categories and > > act_as_list for the articles, but any article should be connected to > > one category. So in any category I can have one or more articles in a > > list. Do I have to declare a Category class as parent of the list of > > the articles? As you might guess I am a Ruby and Rails rookie. > > > I would like to know if there is a plug-in with this features, where I > > can manage categories and articles. > > Apologies if you have already done this but I recommend newcommers to > look at the rails guides athttp://guides.rubyonrails.org/ > particularly Getting Started and ActiveRecord Associations. These may > answer some of your questions. > I had a look and I wll start soon to read migrations and ActiveRecord chapters in "Agile Web Development in Rails" > Are you sure you need a _list_ of articles as opposed to just a > collection of them such as would be provided by the normal has_many, > belongs_to relationship? Let's say you have some articles and the administrator wants to order the articles display. Showing the articles using act_as_list is perfect, since I want to show the articles as and ordered list. > > Colin --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: How to install country_select plug-in
Running the plugin install command from your rails directory should work. Run the following command from your CMD. make sure you are in your rails directory when running the installation script. script/plugin install should work. this will download the plugin ad put it in the "/vendor/plugin" folder. and as the helper function is defined under lib folder you should readily get the method in your views. let us know it worked or not. Thank you :) On Sep 25, 4:49 am, "Thriving K." wrote: > I have downloaded plug-in from. > > http://github.com/rails/country_select > > but i don't know how to install it.. in file install.rb there is only > > # Install hook code here > puts "The list of countries provided by this plugin may offend some > users. Please review it carefully before you use it" > > what is Install hook code ? and how to use it. > > Thank in advance > T. > -- > Posted viahttp://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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: looking for .rhml.r488 instead .rhtml page
Salil Gaikwad wrote: > Hi Priya, > > will you please give the code of list method of the invoice controller. > > > Thanks & Regards, > > Salil Gaikwad Hi Sahil: Thanks for the reply.. But it is not using the code written inside the list method.. i tried clearing the complete code lying in the method and still got the same error.. Actually i have upgraded my application recently from 1.2.3 to 2.3.2. I no its a major upgrade.. bt all set n done.. its wrking fine .. except for this issue.. that too only in this case. Thanks. Priya -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: looking for .rhml.r488 instead .rhtml page
Hi Priya, will you please give the code of list method of the invoice controller. Thanks & Regards, Salil Gaikwad -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Attachment_fu
Thanks robert for sharing the ideas will defiantly implement it. On Thu, Sep 24, 2009 at 8:54 PM, Robert Walker < rails-mailing-l...@andreas-s.net> wrote: > > Robert Walker wrote: > > Maybe ffmpeg would help: > > http://ffmpeg.org/ > > An excerpt from the ffmpeg docs: > > For extracting images from a video: > > ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg > > This will extract one video frame per second from the video and will > output them in files named `foo-001.jpeg', `foo-002.jpeg', etc. Images > will be rescaled to fit the new WxH values. > > If you want to extract just a limited number of frames, you can use the > above command in combination with the -vframes or -t option, or in > combination with -ss to start extracting from a certain point in time. > ... > ... > `-ss position' > Seek to given time position in seconds. hh:mm:ss[.xxx] syntax is also > supported. > ... > ... > `-vframes number' > Set the number of video frames to record. > > This looks to me like it should work well for your needs. > -- > 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] looking for .rhml.r488 instead .rhtml page
Hi All: I am experiencing a strange error. The action request instead of displaying the usual .rhml file is searching for some .rhml.r488 file... log says.. A Errno::ENOENT occurred in invoices#list: No such file or directory - /home/conf.iluminix.com/web/app/views/invoices/list.rhtml.r488 [RAILS_ROOT]/vendor/rails/actionpack/lib/action_view/reloadable_template.rb:88:in `mtime' Any sort of help will be highly appreciated, TIA, Priya Saini -- 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 to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: NoMethodError : undefined method `stringify_keys!' for "2":String
On Sep 25, 10:57 am, maddy wrote: > The "Update" action in controller file looks like this, > > def update > �...@contact = Contact.new(params[:id]) This should be Contact.find Fred > �...@contact.attributes = params[:contact] > �...@contact.save! > redirect_to :action => "index" --~--~-~--~~~---~--~~ 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 rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---