[Rails] Re: Y
I'm sorry: I was handling my phone and I just pressed the most incredible accidental sequence of my life!! Peace. iPhonized! On Dec 29, 2008, at 11:39 PM, emanuele tozzato wrote: > > > iPhonized! --~--~-~--~~~---~--~~ 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] Y
iPhonized! --~--~-~--~~~---~--~~ 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: Wrong number of arguments?
Matt wrote: > You're going to have to isolate what line the error originates from on > your application by going through the Rails trace information, > otherwise we're all going to be here forever trying to figure out what > the problem is. > > On Dec 30, 1:22�am, Ryan Ororie How can I do that? -- 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 app supplying image to a static page?
Can anyone help point me in the right direction on doing the following? Say I have a Rails app that deals with photos at photo.website.com, and I also have a legacy site at www.website.com. What I would like to do is from a static html page on www.website.com have a random photo displayed from the photo app. So, if I put something like this in my static page: would it be possible when a user hits the static page to have it routed to an action that would pull a random photo and return it to the static page in the form of an image? Thanks in advance. Mark --~--~-~--~~~---~--~~ 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: Wrong number of arguments?
You're going to have to isolate what line the error originates from on your application by going through the Rails trace information, otherwise we're all going to be here forever trying to figure out what the problem is. On Dec 30, 1:22 am, Ryan Ororie wrote: > I'm going through a tutorial here and running into an error I'm not sure > how to fix..this is my first foire into sessions. > > Trying to create a shopping cart for a store app. I'm getting this > error: > > wrong number of arguments (1 for 0) > > RAILS_ROOT: script/../config/.. > > Here is my cart_item.rb model: > > class CartItem > attr_reader :product, :quantity > > def initialize > @product = product > @quantity = 1 > end > > def increment_quantity > @quantity += 1 > end > > def title > @product.title > end > > def price > @product.price * @quantity > end > end > > And my cart.rb model: > > class Cart > attr_reader :items > > def initialize > @items = [] > end > > def add_product(product) > current_item = @items.find {|item| item.product == product} > if current_item > current_item.increment_quantity > else > @items << CartItem.new(product) > end > end > end > > And my add_to_cart.rhtml view: > > The shopping cart > > <% for item in @cart.items %> > <%= cart_item.quantity %> × <%= h(item.title) %> > <% end %> > > > When I first tried clicking the add to cart function for a product I got > an error that method 'product' was undefined but then I did rake > db:sessions:clear and now I am getting this wrong number of arguments > error - any ideas? > > Thanks! > -- > 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] Wrong number of arguments?
I'm going through a tutorial here and running into an error I'm not sure how to fix..this is my first foire into sessions. Trying to create a shopping cart for a store app. I'm getting this error: wrong number of arguments (1 for 0) RAILS_ROOT: script/../config/.. Here is my cart_item.rb model: class CartItem attr_reader :product, :quantity def initialize @product = product @quantity = 1 end def increment_quantity @quantity += 1 end def title @product.title end def price @product.price * @quantity end end And my cart.rb model: class Cart attr_reader :items def initialize @items = [] end def add_product(product) current_item = @items.find {|item| item.product == product} if current_item current_item.increment_quantity else @items << CartItem.new(product) end end end And my add_to_cart.rhtml view: The shopping cart <% for item in @cart.items %> <%= cart_item.quantity %> × <%= h(item.title) %> <% end %> When I first tried clicking the add to cart function for a product I got an error that method 'product' was undefined but then I did rake db:sessions:clear and now I am getting this wrong number of arguments error - any ideas? Thanks! -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: changing row color on checkbox click
Scott Kulik wrote: > > but they all produce the same weird result where they don't update until > i click a second time. first click always does nothing. finally got it. it was the :onchange that was causing some issues. i changed it to :onclick and all methods are now working with IE7. thanks again everyone! -- 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] Joins, Joins, Joins! Or Not?
Good morning, I have a quick joins-related question: I have a a list of followings (User following another user's activity) which basically have these followed users' ids under 'followable_id'. now what I want to do and finally have is to take these followed users and check what activities they have. each activity has a .user_id. how would I do this? So Basically A User is following X other Users (polymorphic intermediate model... a User can also follow discussions etc). Each of those users has a set of activities. What I basically want in a 'speedy' way is to get all followed users' activities. I kinda have a problem with the polymorphism of the Follow model, as apparently I cannot put a has_many relationship into the user model which would allow me a condition (followable_type = "User"), class (User) and source (:followable)... I am kinda lost.. been wrangling with join conditions all night :-/ Any ideas / suggestions? Would be highly, highly appreciated...! Cheers, -Joerg --~--~-~--~~~---~--~~ 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: changing row color on checkbox click
Brandon Keepers wrote: > On Mon, Dec 29, 2008 at 11:17 PM, Scott Kulik > wrote: >> another check box the first check box row gets highlighted. >> >> any idea what could be causing the incompatibility with IE? > > Try adding `this`: > > <%= check_box_tag :task, 1, false, > :onchange => > "$(this.parentNode.parentNode).toggleClassName('complete')" %> > > -- > > Training by Collective Idea: Ruby on Rails training in a vacation > setting > http://training.collectiveidea.com � San Antonio, TX � Jan 20-23 same thing :( i found some info here: http://dev.rubyonrails.org/ticket/11078 and the link they reference http://prototypejs.org/learn/extensions...there is a bit at the bottom: // this will error out in IE: $('someElement').parentNode.hide() // to make it cross-browser: $($('someElement').parentNode).hide() soi tried these ways: $(this.parentNode.parentNode).toggleClassName('complete') $($(this).parentNode.parentNode).toggleClassName('complete') $($('make_step18').parentNode.parentNode).toggleClassName('complete') make_step18 is the id of checkbox i was testing. but they all produce the same weird result where they don't update until i click a second time. first click always does nothing. -- 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] Who can consult with me on scaling and architecture?
I'd love to pay someone who has serious scaling experience to talk with me about how to plan for scaling. I'm developing a network of applications in Rails that could see tens of millions of users. I'm in way over my head, so I'd like to talk to someone who's been through it before. I want to know: - how to architect applications to scale smoothly - how to manage the growth in hardware - whether it's a bad idea to go with Rails at all. I'm not really sure where to start looking though. Are there people or companies in the community who consult on these topics? And while we're on it, are there companies that offer part-time sysadmin services for Rails stacks? -- 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: Avoiding ActiveRecord loading for efficiency with lots of rows
Greg Brockman wrote: > Hello all, > > This is my first post to this group, so please let me know if there is > any protocol I'm supposed to follow that I missed. Anyway, I've been > developing a Rails application for handling the registration and score > data of a math competition. There is an existing Java applet that we > use that generates the score data with reference to problem_id, > solver_id, and the result (which is - if blank, 0 if wrong, 1 if > right, and =n if n points of partial credit are to be awarded). It > saves each individual's answer to each question as a separate row in > the scores table. > > I've wrote a script to process this data in Rails. However, in 2008 > there were over 15,000 rows in the scores table, and my current code > loads every one of them. My current load time is about 5 seconds, and > I think it's due to making an ActiveRecord object for every one. Is > there a way to bypass making a separate object for each? I do need > access to the data, but it would be nicest as an array or something > under Solver. One solution I'm currently considering is using raw SQL > for this, but I thought I'd see if anyone had any thoughts to weigh > in. > > Thanks a lot! > > Greg http://enterpriserails.rubyforge.org/hash_extension/ Haven't tried this myself, but it should be faster than loading 15k ActiveRecord objects. -- 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: changing row color on checkbox click
On Mon, Dec 29, 2008 at 11:17 PM, Scott Kulik wrote: > > Scott Kulik wrote: >> Mark Reginald James wrote: >>> Scott Kulik wrote: i'm not that familiar with javascript so i'm not sure how i would finish this. thanks! >>> >>> <%= check_box_tag :task, 1, false, >>> :onchange => "$(parentNode.parentNode).toggleClassName('complete')" %> >>> >>> -- >>> Rails Wheels - Find Plugins, List & Sell Plugins - >>> http://railswheels.com >> >> perfect! thank you so much mark! > > oops spoke a little too soon. the highlighting works great on firefox 3 > but for some reason it acts a little weird on IE7. > > the first check box i click doesn't do anything but then if i click > another check box the first check box row gets highlighted. > > any idea what could be causing the incompatibility with IE? Try adding `this`: <%= check_box_tag :task, 1, false, :onchange => "$(this.parentNode.parentNode).toggleClassName('complete')" %> -- Training by Collective Idea: Ruby on Rails training in a vacation setting http://training.collectiveidea.com – San Antonio, TX – Jan 20-23 --~--~-~--~~~---~--~~ 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: changing row color on checkbox click
Scott Kulik wrote: > Mark Reginald James wrote: >> Scott Kulik wrote: >>> >>> i'm not that familiar with javascript so i'm not sure how i would finish >>> this. thanks! >> >> <%= check_box_tag :task, 1, false, >> :onchange => "$(parentNode.parentNode).toggleClassName('complete')" %> >> >> -- >> Rails Wheels - Find Plugins, List & Sell Plugins - >> http://railswheels.com > > perfect! thank you so much mark! oops spoke a little too soon. the highlighting works great on firefox 3 but for some reason it acts a little weird on IE7. the first check box i click doesn't do anything but then if i click another check box the first check box row gets highlighted. any idea what could be causing the incompatibility with IE? -- 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: Making a Little Application
Sorry for the bump, but I am about to begin the rewrite and am wondering if there is some way to do this in Rails. --~--~-~--~~~---~--~~ 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: index => nil params jumbled *sometimes*
> Those first three fields are not enclosed in a cell. > That may cause IE to send the parameters in the wrong order. > > Please log and post the raw_post string. Ahh, IE, my old friend. Perhaps this is why I wasn't able to recreate it. Here is the raw POST: Processing TimeCardsController#day (for 192.168.1.192 at 2008-12-18 09:14:13) [POST] Parameters: {"date"=>"2008-12-17", "time_cards"=>[{"job_id"=>"3107", "time_card_entry_type"=>"Field", "time_card_date"=>"2008-12-17", "id"=>"285875", "note"=>"Akron e-rate cable project counts/ FSR presentation", "hours"=>"2", "user_id"=>"178"}, {"time_card_date"=>"2008-12-17", "id"=>"285774", "user_id"=>"178"}, {"job_id"=>"3089", "time_card_entry_type"=>"Field", "time_card_date"=>"2008-12-17", "id"=>"", "note"=>"progress drawing and spec revision", "hours"=>"2.5", "user_id"=>"178"}, {"job_id"=>"3107", "time_card_entry_type"=>"Field", "note"=>"Akron e- rate cable project counts", "hours"=>"2"}]} --~--~-~--~~~---~--~~ 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: AJAX select box dropdown update form
On Mon, Dec 29, 2008 at 6:07 PM, Allen Walker < rails-mailing-l...@andreas-s.net> wrote: > > I have the following form with 2 selectbox drop downs: > > SelectBox1 > > SelectBox2 > > WHen the user changes the selection in SelectBox1, I want SelectBox2 to > be updated to contain a different set of > options. I'm not sure exactly how to do this. If someone could point me > in the right direction, I'd appreciate it. I followed the outline given at http://pullmonkey.com/2008/3/30/dynamic-select-boxes-ruby-on-rails when I wanted to do this a couple of weeks ago. --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: changing row color on checkbox click
Mark Reginald James wrote: > Scott Kulik wrote: >> >> i'm not that familiar with javascript so i'm not sure how i would finish >> this. thanks! > > <%= check_box_tag :task, 1, false, > :onchange => "$(parentNode.parentNode).toggleClassName('complete')" %> > > -- > Rails Wheels - Find Plugins, List & Sell Plugins - > http://railswheels.com perfect! thank you so much mark! -- 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: changing row color on checkbox click
Scott Kulik wrote: > say for example i had something simple like this in a view: > > <%= check_box_tag(:task) %> > > how would i add onclick to change the row color on a check and when the > check is removed? > > maybe something like this? > > page[task].addClassName('complete') > > i'm not that familiar with javascript so i'm not sure how i would finish > this. thanks! <%= check_box_tag :task, 1, false, :onchange => "$(parentNode.parentNode).toggleClassName('complete')" %> -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.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: Gem version issue prevent server starting
Sorry about the name change Kevin... On Dec 29, 2:42 pm, Rick wrote: > Andreas, > > RAILS_GEM_VERSION should match the version number of your installed > rails. i.e.: on my system, > rails --version gives Rails 2.2.2 > thus, RAILS_GEM_VERSION = '2.2.2' is correct. > > 1.3.1 is probably the version of gem you have installed > > rick > > On Dec 29, 11:13 am, kevin lee > wrote: > > > Hi All, > > > I backed up my rails project and then reinstall Windows due to OS crash. > > Then I install the latest Ruby, RubyGem, and Rails and copy back the > > rails project. But now I cannot start the server (ruby script/server). > > It gives the following message: > > > ./script/../config/boot.rb:26:Warning: Gem:SourceIndex#search support > > for String patterns is deprecated Cannot find gem for Rails ~>1.3.1.0: > > Install the missing gem with 'gem install -v=1.3.1 rails', or change > > environment.rb to define RAILS_GEM_VERSION with your desired location. > > > I changed environment.rb's RAILS_GEM_VERSION to 1.3.1 but it does not > > have an effect. Then I tried to install the missing gem as listed above > > (I think it is already installed but I try it anyway) and got the error > > message: Could not find gem rails locally or in a depository. > > > How can I solve this problem? Should I start a new app for my existing > > project? > > Please enlighten. Thanks! > > -- > > 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: Gem version issue prevent server starting
Andreas, RAILS_GEM_VERSION should match the version number of your installed rails. i.e.: on my system, rails --version gives Rails 2.2.2 thus, RAILS_GEM_VERSION = '2.2.2' is correct. 1.3.1 is probably the version of gem you have installed rick On Dec 29, 11:13 am, kevin lee wrote: > Hi All, > > I backed up my rails project and then reinstall Windows due to OS crash. > Then I install the latest Ruby, RubyGem, and Rails and copy back the > rails project. But now I cannot start the server (ruby script/server). > It gives the following message: > > ./script/../config/boot.rb:26:Warning: Gem:SourceIndex#search support > for String patterns is deprecated Cannot find gem for Rails ~>1.3.1.0: > Install the missing gem with 'gem install -v=1.3.1 rails', or change > environment.rb to define RAILS_GEM_VERSION with your desired location. > > I changed environment.rb's RAILS_GEM_VERSION to 1.3.1 but it does not > have an effect. Then I tried to install the missing gem as listed above > (I think it is already installed but I try it anyway) and got the error > message: Could not find gem rails locally or in a depository. > > How can I solve this problem? Should I start a new app for my existing > project? > Please enlighten. Thanks! > -- > 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] changing row color on checkbox click
say for example i had something simple like this in a view: <%= check_box_tag(:task) %> how would i add onclick to change the row color on a check and when the check is removed? maybe something like this? page[task].addClassName('complete') i'm not that familiar with javascript so i'm not sure how i would finish this. thanks! -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Finding Child Records Efficiently
DAZ wrote: > On Dec 28, 8:07 pm, Mark Reginald James wrote: > >> One alternative is to make the ancestor array a string key >> to each record ("abe|homer|bart"), allowing instant retrieval. > > This seems like a relatively good idea, could have a string-key called > family_tree or something and just do find_by_family_tree("abe|homer| > bart") > This doesn't quite feel right - it seems like the only info you should > need to keep is a person's parent (from which you can then find their > parent and so forth). It might also lead to some very long strings > eventually! It does require maintenance: whenever a name changes you have to update the string in all children and all ancestors. >> Another would be to build the sql iteratively: >> > > This is what I'm doing at the moment - I'm using the "betternestedset" > plugin, so have access to a "children" method that returns an arrary > of children. Will this have all been pre-fetched efficiently? And if > so, is the iterative code the way to do it? > >tree = ["abe","homer","bart"] > person = Person.find_by_name(tree[0]) > if tree.size > 1 > 1.upto(tree.size - 1) do |i| > person = person.children.find { |child| child.name == tree > [i] } > end > end > @person = person First-generation children are efficiently retrieved in both better_nested_set and acts_as_tree via the parent key. better_nested_set also allows you to efficiently retrieve all generations of children using the all_children method. So your current method will be making one DB call per generation. And you should put the name match into the SQL conditions rather than in a Ruby loop. But have a look at the code in my last post. It can find the correct Bart using only one DB call by matching up the unique ancestors chain. -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.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: index => nil params jumbled *sometimes*
Matt Darby wrote: > > >type="hidden" value="121" /> > > > Those first three fields are not enclosed in a cell. That may cause IE to send the parameters in the wrong order. Please log and post the raw_post string. -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.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] AJAX select box dropdown update form
I have the following form with 2 selectbox drop downs: SelectBox1 SelectBox2 WHen the user changes the selection in SelectBox1, I want SelectBox2 to be updated to contain a different set of options. I'm not sure exactly how to do this. If someone could point me in the right direction, I'd appreciate it. Thanks -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Installing Plugins Offline?
Marnen Laibow-Koser wrote: > On Dec 29, 2:52�pm, Robert Walker > wrote: >> sa 125 wrote: >> > How would I go about installing rails plugins offline? I cannot connect >> > to the web on my work computer, though I have a dedicated internet >> > machine for downloads and such. >> >> This is precisely why I generally prefer gems over plugins, > > How does using gems help at all? It seems to me that gems would > suffer from precisely the same problem as plugins here. It helps because the more common gems are likely already installed on my system. All I need to do for a new project is to add the gem dependency to the environment.rb file. The command to install a plugin wants to go out and download the plugin from the internet. Yes, obviously, if I don't have the gem installed I would still need an internet connection, but I don't have to do any coping or hacking around to copy a plugin from some obscure location in my local system. Example: config.gem "rubist-aasm", :lib => "aasm" This line added to my environment.rb file is all I need to do in a new project to use the aasm gem that I likely already have installed on my system. > And I think an unfortunate one. Unless there's something I don't > understand about gem packaging (which is quite possible :) ), it seems > to me that while it's easy to install a plugin into one app without > affecting the whole environment, it's hard to do so for a gem. (Yes, > I know about frozen gems, but the usual way of doing that is to > install the gem on the development computer first, then freeze it into > the app.) I often need to install gems on my local machine in order > to work on clients' projects (after all, not everyone freezes their > gems), and I wish it wasn't necessary -- I don't want to change my > entire operating environment for the sake of one project. > Gems are the "standard" packaging for Ruby (not specifically Rails). Using gems is natural for Ruby developers and using gem dependencies in Rails is a more natural fit than plugins for sharing code. I think of them in a similar way as I think about "Frameworks" in my Cocoa development. I like that there is basically one way to share code between different applications when doing Mac development. Plugins, in my mind, are a different thing. A plugin architecture is a means of extending an application's capabilities and not simply a means of sharing code between different applications. So yes, maybe plugins do have a place in this context, but that is not generally how Rails plugins are used. I realize this is subjective, but I do prefer sharing code through gems rather than plugins. > I like gems for things like RSpec that I actually use on every > project. But I hope the day never comes when I have to install a > special-purpose gem for just one app because it doesn't exist as a > plugin. > Rspec is actually a really good example. It was a plugin and is now a gem. I prefer it as a gem because I might want to share it between multiple applications. I only have to maintain one repository of "framework" code. If I need a specific application to depend on a specific version of rSpec I simply tell it that in it's environment.rb file. config.gem "rspec-rails", :lib => "spec", :version => "1.1.11" Then I can see all my dependencies quickly and easily in a terminal: $ rake gems - [I] rubyist-aasm - [I] rspec-rails - [I] rspec = 1.1.11 - [ ] hoe >= 1.8.1 - [ ] rubyforge >= 1.0.1 - [I] rake = 0.8.3 I = Installed F = Frozen R = Framework (loaded before rails starts) And manage my application's environment with the various rake gems:xxx commands. -- 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: Finding Child Records Efficiently
DAZ wrote: > On Dec 28, 8:07�pm, Mark Reginald James wrote: > >> One alternative is to make the ancestor array a string key >> to each record ("abe|homer|bart"), allowing instant retrieval. > > This seems like a relatively good idea, could have a string-key called > family_tree or something and just do find_by_family_tree("abe|homer| > bart") > This doesn't quite feel right - it seems like the only info you should > need to keep is a person's parent (from which you can then find their > parent and so forth). It might also lead to some very long strings > eventually! I tend to like this idea as well, and is probably what I would do. The caching of the ancestry would seem to be the most efficient. However, there is one change I would make. I would reverse the ancestry so it would be ("bart|homer|abe"). Doing this would make string comparisons more efficient because you are looking for "bart" so having "bart" at the beginning of the string may slightly increase the string comparison efficiency. > This doesn't quite feel right - it seems like the only info you should > need to keep is a person's parent (from which you can then find their > parent and so forth). It might also lead to some very long strings > eventually! This, however, I don't agree with. You need the full ancestry to whatever the "root" objects is. The idea is to make one comparison with no joins. The only way to do that I can think of is to have all the information available at the row level. If you end up with a very deep hierarchy, which would result in very long strings, you could consider hashing the strings. This way you would have a consistent length string to compare. Example MD5 Hash: bart|homer|abe = a92b11363ef020716f1ce3104e0cb0d8 (32 chars) bart|homer|abe|john|william|ted|sam|joeseph|adam|bart|bill|jack = ff2f4ad181a029935b89a36c7cd1dfbe (32 chars) Obviously in some cases your losing rather than gaining, but at least the string is consistent in length no matter how long the input string becomes. -- 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: Avoiding ActiveRecord loading for efficiency with lots of rows
Quoting Greg Brockman : > > Hello all, > > This is my first post to this group, so please let me know if there is > any protocol I'm supposed to follow that I missed. Anyway, I've been > developing a Rails application for handling the registration and score > data of a math competition. There is an existing Java applet that we > use that generates the score data with reference to problem_id, > solver_id, and the result (which is - if blank, 0 if wrong, 1 if > right, and =n if n points of partial credit are to be awarded). It > saves each individual's answer to each question as a separate row in > the scores table. > > I've wrote a script to process this data in Rails. However, in 2008 > there were over 15,000 rows in the scores table, and my current code > loads every one of them. My current load time is about 5 seconds, and > I think it's due to making an ActiveRecord object for every one. Is > there a way to bypass making a separate object for each? I do need > access to the data, but it would be nicest as an array or something > under Solver. One solution I'm currently considering is using raw SQL > for this, but I thought I'd see if anyone had any thoughts to weigh > in. > There are several ways: * A Problem has_many Scores, a Solver has_many Score, and A Score belongs_to both a Problem and a Solver. Process one Problem at a time, or one Solver at a time. * SQL, e.g. select_rows('SELECT problem_id, solver_id, result FROM scores') Returns an array of array of strings with the values in the order specified. E.g. [['123', '345', '-'], # problem 123, solver 345, result '-' ['124', '1024', '123'], # problem 123, solver 1024, result '123' ... Remember, all values are strings and may need to be converted to integers. * Use will_paginate to retrieve results in clumps, e.g. 100 results at a time. HTH, Jeffrey --~--~-~--~~~---~--~~ 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: Sending SMS Messages From Your Rails Application Usng Cl
Hi Walter, Are you able to successfully send an SMS using the sms command line utility bundled with the gem? Try enabling the library debug mode - you should then be able to see the raw HTTP requests being sent. -- 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] Gem version issue prevent server starting
Hi All, I backed up my rails project and then reinstall Windows due to OS crash. Then I install the latest Ruby, RubyGem, and Rails and copy back the rails project. But now I cannot start the server (ruby script/server). It gives the following message: ./script/../config/boot.rb:26:Warning: Gem:SourceIndex#search support for String patterns is deprecated Cannot find gem for Rails ~>1.3.1.0: Install the missing gem with 'gem install -v=1.3.1 rails', or change environment.rb to define RAILS_GEM_VERSION with your desired location. I changed environment.rb's RAILS_GEM_VERSION to 1.3.1 but it does not have an effect. Then I tried to install the missing gem as listed above (I think it is already installed but I try it anyway) and got the error message: Could not find gem rails locally or in a depository. How can I solve this problem? Should I start a new app for my existing project? Please enlighten. Thanks! -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: SQL tool
On Dec 29, 10:29 am, David Nguyen wrote: > Hi, > > I'm looking for a tools under windows that can draw a SQL map using a > sql file and ruby convention. So relations are kept and I can get a nice > gif or jpeg file > with my DB schema. Well, if your DB has the foreign key constraints in it (and it should -- check out http://www.redhillonrails.org for an easy way to do that), then you could use a tool like Power*Architect ( http://www.sqlpower.ca/page/architect ) to quickly draw the ER diagrams. > > Thanks :-) Best, -- Marnen Laibow-Koser mar...@marnen.org http://www.marnen.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: expires_in with fragment-caching
Quoting sigma : > > Hi all > > Is it posible do have a expires_in with fragment-caching? Does this > work with memcached? > Yes, though memcached is the only mechanism it is already built-in. There is a way that works with the other three mechanisms (I think, I've only tried it with memory_store). If anyone is interested, I'll post it on my blog. Jeffrey --~--~-~--~~~---~--~~ 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: Installing Plugins Offline?
On Dec 29, 2:52 pm, Robert Walker wrote: > sa 125 wrote: > > How would I go about installing rails plugins offline? I cannot connect > > to the web on my work computer, though I have a dedicated internet > > machine for downloads and such. > > This is precisely why I generally prefer gems over plugins, How does using gems help at all? It seems to me that gems would suffer from precisely the same problem as plugins here. > Now that > Rails has good support for gem dependencies I expect to see most plugins > converted to gems. This already seems to be a pretty popular trend. And I think an unfortunate one. Unless there's something I don't understand about gem packaging (which is quite possible :) ), it seems to me that while it's easy to install a plugin into one app without affecting the whole environment, it's hard to do so for a gem. (Yes, I know about frozen gems, but the usual way of doing that is to install the gem on the development computer first, then freeze it into the app.) I often need to install gems on my local machine in order to work on clients' projects (after all, not everyone freezes their gems), and I wish it wasn't necessary -- I don't want to change my entire operating environment for the sake of one project. I like gems for things like RSpec that I actually use on every project. But I hope the day never comes when I have to install a special-purpose gem for just one app because it doesn't exist as a plugin. Best, -- Marnen Laibow-Koser mar...@marnen.org http://www.marnen.org > -- > 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: 2.2.2 simple_captcha upgrade error
richard$ gem list ... postgres-pr (0.4.0) ... richard$ sudo gem install postgres-pr Password: Successfully installed postgres-pr-0.5.0 richard$ script/server => Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails 2.2.2 application starting on http://0.0.0.0:3000 It worked great, Thanks!! No problems starting up or showing any of my database entries, my app works just as it did before. Thanks for everyone's help!! -- 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: Your thoughts on "Enterprise Rails"
On Dec 28, 11:46 am, Wayne Molina wrote: > Hello and happy holidays, everyone! > > I received the book "Enterprise Rails" by Dan Chak as a Christmas gift > and started reading it; I wanted to gauge the community's thoughts on > this. I was just looking at the book (© 2009!) in the local Barnes & Noble. That means that I haven't really had a chance to read it in depth, but it looked very interesting. I apparently did not get to any of the sections that you did, because what you describe below is news to me. One of the things I *did* notice, however, is that this book gives one of the few good explanations I've seen of how to write Rails plugins, and why you'd want to. > Basically, Mr. Chak advocates a totally different approach to > how every other Rails book/tutorial explains how to develop Rails > applications. > > Firstly, he advocates you organize your application deeper than the > default Rails skeleton; for example he says to put all of your models > under a "physical" directory (e.g. app/models/physical) and to > separate them by module (e.g. Physical::Projects::Project). I suppose there could be some benefit in this on very large projects, but I tend to think it's overkill if you don't have lots of models. > > He also evangelizes Postgresql instead of MySQL, Good for him! PostgreSQL is certainly the best choice for *any* project, not just big ones. (I gave up on mySQL about 2 years ago, and I've been a lot happier since.) For some reason, it doesn't get enough love in the open-source Web development community. Basically, anything mySQL can do, PostgreSQL can do better, and it's really the only open-source choice if you're doing anything spatial or using non- trivial stored procedures. (I've heard that PostgreSQL clusters less well than mySQL, but I've never worked with clustered DB servers in either case.) > and suggests not > using migrations at all but using raw SQL to create the tables, > because he recommends that you NOT treat the database like a dumb data > store (something the rest of the Rails community seems to do and be > okay with) and make good use of check constraints, triggers, > referential integrity and the like at both the database level AND the > application level. He is against migrations because of the extremely > limited subset of SQL they allow for (i.e. no real constraints). Hmm. If this is what Chak really wrote, I wonder if he actually understands migrations. As Kevin and others have said, if that's an accurate description of what he wrote, he apparently doesn't realize that migrations allow the use of raw SQL, and he would also appear to be unaware of the excellent plugins from RedHill Consulting ( http://www.redhillonrails.org/ ), which address these very issues by adding constraints, transactions, and referential integrity to Rails migration syntax. [...] > The problem with using the approach from Enterprise Rails is > that it pretty much means I cannot use the generators, unless I were > to redefine them to follow the "enterprise" structure. While that's > not a big deal, I can't help but think that I would be going "against > the grain" as far as my application is concerned - call me a bandwagon > jumper, but I always prefer to follow the community when it comes to > programming, instead of going off on my own. Sure. Without having read the book, I don't know what I think of Chak's organizational suggestions, but it wouldn't be too hard to write new generator scripts for them if they're worth adopting. > > From reading the book, though, I can't seem to understand why the > Rails community has never done this from the start. Rails > applications are meant to be scalable, no? And the big ones have got > to scale if they get successful, right? You would think. But scalability and YAGNI are often perceived to be in conflict in early stages of development. > The Rails app that Dan Chak > worked on, according to what he says in the book, ballooned to some > 188 classes; if other large Rails apps are like that, how do they > manage? I would think that 188 classes in a Rails app would be a design smell, not something to brag about. Surely in most cases, an app with that many classes should be segmented into several related apps, perhaps following some of the ideas at http://revolutiononrails.blogspot.com/2007/01/plugems-rails-as-first-class-citizens.html (note: I haven't tried these ideas, but they seem reasonable). > > Basically - I'm wondering if I should be following the advice in the > book from the get-go when I design my application, or if I should > follow the best practices of the Rails community and not worry about > the "enterprise" stuff until I need to (at which point it may or may > not be too late). I would vote for the latter approach. If you have good test coverage, refactoring for scalability when necessary shouldn't be a big deal. > Also remember that I am fai
[Rails] Avoiding ActiveRecord loading for efficiency with lots of rows
Hello all, This is my first post to this group, so please let me know if there is any protocol I'm supposed to follow that I missed. Anyway, I've been developing a Rails application for handling the registration and score data of a math competition. There is an existing Java applet that we use that generates the score data with reference to problem_id, solver_id, and the result (which is - if blank, 0 if wrong, 1 if right, and =n if n points of partial credit are to be awarded). It saves each individual's answer to each question as a separate row in the scores table. I've wrote a script to process this data in Rails. However, in 2008 there were over 15,000 rows in the scores table, and my current code loads every one of them. My current load time is about 5 seconds, and I think it's due to making an ActiveRecord object for every one. Is there a way to bypass making a separate object for each? I do need access to the data, but it would be nicest as an array or something under Solver. One solution I'm currently considering is using raw SQL for this, but I thought I'd see if anyone had any thoughts to weigh in. Thanks a lot! Greg --~--~-~--~~~---~--~~ 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] Help with model association
Hi, I'm very new to RoR so my question may be bit stupid. I'm trying to create application that could serve as training log. So I have "Trainee" who goes to a gym. What he/she does is a "Workout" (and there is a bunch of them in list to choose from). Now there are many Trainees in a gym at a same time having different (or same possibly) Workout. So I have a table with Trainees, table with Workouts and I would like to join them in Trainings ( Trainee id_1 did Workout id_2, Trainee id_2 did Workout id_4, both at 6 pm on 28.12.2008). One Training has many Trainees each with different or same Workout. Trainees and Workouts are connected together by join table with one additional value of date and time of training. At the beginning my idea was this class Trainee < ActiveRecord::Base has_many :trainings has_many :workouts, :through => :trainings end class Training < ActiveRecord::Base belongs_to :workouts belongs_to :trainee end class Workouts < ActiveRecord::Base has_many :trainings has_many :trainees, :through => :trainings end But I don't want to create new Trainee with new Workouts, both would be more or less stable (list of Trainees and list of Workouts to choose from). I would like to add new Training, choose date&time, choose Trainees (one or more) and attach Workouts to them (same or different to each) (so multiple Trainees on one Training, each Trainee with one his own Workout). My queries should be something like - who did Workout_id1 with best time - which Workouts Trainee_id2 did in last 30 days - who attended Training on 28.12.2008 etc. Is my association model correct ? Could I use join table directly like this ?. Thank you very much Petr Ruzicka --~--~-~--~~~---~--~~ 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: Installing Plugins Offline?
sa 125 wrote: > How would I go about installing rails plugins offline? I cannot connect > to the web on my work computer, though I have a dedicated internet > machine for downloads and such. This is precisely why I generally prefer gems over plugins, Now that Rails has good support for gem dependencies I expect to see most plugins converted to gems. This already seems to be a pretty popular trend. -- 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: ApplicationController: understanding generate scaffold
On Mon, Dec 29, 2008 at 2:22 PM, Sarah Allen < rails-mailing-l...@andreas-s.net> wrote: > Patrick Doyle wrote: > > From one newbie to another... > > Look at the links created in the index view for your tasks controller. > > With > > the default scaffold, you should see three links to the right of each > > task > > listed: Show, Edit, and Destroy. If you mouse-over the Edit link, you > > will > > probably see something that looks like: > > http://localhost:3000/tasks/1/edit. > > That says to the routing system in Rails (through the magic of the code > > you > > wrote in config/routes.rb) > > hmm. If I look at the routes that were auto-generated for me, I see: > map.connect ':controller/:action/:id' > > which would lead me to believe that the URL should be: > http://localhost:3000/tasks/edit/1 > > while semantically it makes more sense to apply the edit action last, I > don't see how that maps to the code. Is it considered bad practice to > leave these as is. The comment says "consider removing the them or > commenting them out if you're using named routes and resources." I'm > not quite sure what "named routes and resources" are and whether I'm > using them. > Look at the top of your routes file. You will see something that looks vaguely like: map.resources :tasks That creates routes that match /tasks/1/edit Oh cool... I just realized that using the RESTful routes created by map.resources, and using the default route at the end of routes file, you would get to exactly the same place via: http://localhost:3000/tasks/1/edit and http://localhost:3000/tasks/edit/1 If that sort of thing bothers you, you could "consider removing [the default rules] or commenting them out if you're using named routes and resources" Oh, I just saw the part in your email about the "named routes and resources". Since you are using the scaffold, you are using named routes and resources, since that is what is considered to be the best practice by those who brought you Rails. Google "RESTful routing" and you will find much more information than I could provide in an email. But, in a nutshell, the "map.resources" command at the top of the file creates a bunch of routes for you that map to the 7 actions you found in your controller. With those in place, you don't need the two default routes at the end of the file. > >"Invoke the 'edit' action in the 'tasks' > > controller, and, by the way, set the 'id' parameter to '1'". > > > > When your #edit action is invoked, it searches the Task table in your > > database for the entry with an ID of 1. Then Rails, by default, will > > render > > a view (a web page) named "edit". You can see the template for that web > > page in app/views/edit.html.erb. > > > > If you completely remove the #edit action, the default behavior is still > > to > > render a template with the same name as the action. > > Yes, it does this, but when the template is rendered, it causes the > error below, which I assume is because '@task' is not defined, although > I don't really understand the error message. > Oops, I thought about that after I sent my email. But by then I figured you would have noticed it yourself :-) The error message is produced because @task evaluates to nil. Something somewhere in the #form_for helper tried to call @task.id, which got evaluated as nil.id, which triggered an exception, which displayed an error message indicating that you probably didn't want to do that. I see empirically how it works; however, I'm still curious how does > Rails "know" whether I've called respond_to in my edit method? > > The respond_to stuff has to do with "Web Services" whatever those are. (Keep in mind, I'm a newbie here too.) From what I've intuited so far, web services seem to like to exchange data using XML. I don't really know why #edit doesn't include a call to respond_to where each of the other 6 actions do, except to note the use of #edit in the world of RESTful routing. In that world, when you want to create a new record in a table, you are first presented with a view of a blank record (via the #new action). When you click on the "Create" button, the #create action gets invoked. In the same vein, when you want to edit an existing record, you are first presented with a view of the existing record (via the #edit action). When you click on the "Update" button, the #update action gets invoked. My guess is that, in the web services world, one would never invoke an "update" action without first having some idea of what the data looked like and that one would probably have learned that via the #show action, so that rendering something in XML for #edit is not necessary. In the web brower world, the "show" view displays data on a page while the "edit" view would presumably display a form (with the exact same data) allowing the end user to change the data and submit an update. That's my guess anyway. --wpd --~--~-~--~~~---~--~~ You received this message
[Rails] Re: ApplicationController: understanding generate scaffold
Patrick Doyle wrote: > If you look in app/controllers/application.rb, you will find that > ApplicationController is a task that you derived from > ActionController::Base. You should be able to find documentation about > ActionController::Base at http://api.rubyonrails.org/ ah. This solves the first mystery. Still learning all the stuff that gets generated with scaffold. > From one newbie to another... > Look at the links created in the index view for your tasks controller. > With > the default scaffold, you should see three links to the right of each > task > listed: Show, Edit, and Destroy. If you mouse-over the Edit link, you > will > probably see something that looks like: > http://localhost:3000/tasks/1/edit. > That says to the routing system in Rails (through the magic of the code > you > wrote in config/routes.rb) hmm. If I look at the routes that were auto-generated for me, I see: map.connect ':controller/:action/:id' which would lead me to believe that the URL should be: http://localhost:3000/tasks/edit/1 while semantically it makes more sense to apply the edit action last, I don't see how that maps to the code. Is it considered bad practice to leave these as is. The comment says "consider removing the them or commenting them out if you're using named routes and resources." I'm not quite sure what "named routes and resources" are and whether I'm using them. >"Invoke the 'edit' action in the 'tasks' > controller, and, by the way, set the 'id' parameter to '1'". > > When your #edit action is invoked, it searches the Task table in your > database for the entry with an ID of 1. Then Rails, by default, will > render > a view (a web page) named "edit". You can see the template for that web > page in app/views/edit.html.erb. > > If you completely remove the #edit action, the default behavior is still > to > render a template with the same name as the action. Yes, it does this, but when the template is rendered, it causes the error below, which I assume is because '@task' is not defined, although I don't really understand the error message. Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id Extracted source (around line #3): 1: Editing task 2: 3: <% form_for(@task) do |f| %> 4: <%= f.error_messages %> 5: 6: > If you leave the #edit action in there, but don't do anything in it, the > default behavior is still to render a template with the same name as the > action. yup. same behavior. > If you leave the code in there as written, the #edit action will fetch > the > row from the Task database with the specified ID. The #edit view will > then > have some data to show when it displays the form. Makes sense. I see empirically how it works; however, I'm still curious how does Rails "know" whether I've called respond_to in my edit method? Thanks so much, Sarah -- 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] member on has_one or has_many
Hi, I was wondering if it is possible todo something like this in the routes file: map.namespace(:admin) do |admin| admin.resources :dashboard, :only => [ :index ], :has_one => :something, :member => [ :action => :get ], :has_many => [ :something_else ,:more_something ] end The problem is the member in the has_one declaration, the member is added to the dashboard and not the something controller. I tried wrapping in [] and {} but no luck... I got it working using :dashboard do BUT I would like to have the nice :has_one :has_many... Anyone? PS I guess If I want to use :only and :except for the has_one this also applies... --~--~-~--~~~---~--~~ 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: index => nil params jumbled *sometimes*
Anyone else by chance? It really seems like this is a lower level error... --~--~-~--~~~---~--~~ 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] text_field or text_field_tag
Hi, I'm watching Ryan Bates' forms screencast #1, and he says that I should use text_field when I'm updating an object, otherwise text_field_tag. How about this: I'm looping through each row of a table and displaying form for each. (but there's only one form, because I want it to be submited all at once). Now I'm not sure how should I do it, so far I have something like text_field("item_#{item.id}", "title", {:value => item.title}); Is this a good way? --~--~-~--~~~---~--~~ 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: Preventing a form from submitting on ENTER
I believe if you put a textarea in your form, the browser will not submit the form if you hit the enter key. It depends on which browser you are using though. On Mon, Dec 29, 2008 at 11:18 AM, Robert Walker < rails-mailing-l...@andreas-s.net> wrote: > > Ivor Paul wrote: > > How about removing form tags - just have the field and the observe_field > > this might not be valid html - not sure about that. > > > "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";> > > http://www.w3.org/1999/xhtml"; xml:lang="en"> > > untitled > > > >Test value="" id="test" /> > > > > > > > The above code passes the W3C validator for XHTML 1.0 Strict and XHTML > 1.1. Notice that the surrounding the and was > necessary to pass XHTML Strict, but was not required for XHTML 1.0 > Transitional. Other surrounding tags besides work as well, but the > and tags must be contained by something. > > Example (this is INVALID!): > -- > > "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";> > > http://www.w3.org/1999/xhtml"; xml:lang="en"> > > untitled > > > Test id="test" /> > > > > W3C Validator: > Line 10, Column 19: document type does not allow element "label" here; > missing one of "ins", "del", "h1", "h2", "h3", "h4", "h5", "h6", "p", > "div", "address", "fieldset" start-tag. > -- > > -- > 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: add an editor on my application
+1 for Textile or Markdown (my preference) ... try looking up rdiscount if you want to use Markdown, I'm sure there are better options out there. On Dec 29, 9:11 am, "Ivor Paul" wrote: > Hi > > I have limited experience with FCKEditor --http://www.fckeditor.net/ > > and slightly more exp with tinymce --http://tinymce.moxiecode.com/ > > but in my experience the better solution is to use textile > ->http://redcloth.org/&http://wiki.rubyonrails.org/rails/pages/RedClothsincethey > are simpler > and then harder for users to break. TinyMCE imho > gives the user to many options and since most people are not good with > layout they often make a bigger mess than if you gave them something like > redcloth/textile > > Regards > > On Mon, Dec 29, 2008 at 11:52 AM, Johny ben < > > rails-mailing-l...@andreas-s.net> wrote: > > > Does anyone have a good suggestion for the best editor that can I embed > > on my application.. > > -- > > 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: Your thoughts on "Enterprise Rails"
While I don't agree with much of what the book seems to be saying ... I'm an opinionated b...@$tard ... there are always things you can learn even from books that don't seem to be the best. I have some really crappy programming/technology books at home, but I could still learn a lot from them because the background allowed me to sift out the stuff. On Dec 28, 10:46 am, Wayne Molina wrote: > Hello and happy holidays, everyone! > > I received the book "Enterprise Rails" by Dan Chak as a Christmas gift > and started reading it; I wanted to gauge the community's thoughts on > this. Basically, Mr. Chak advocates a totally different approach to > how every other Rails book/tutorial explains how to develop Rails > applications. > > Firstly, he advocates you organize your application deeper than the > default Rails skeleton; for example he says to put all of your models > under a "physical" directory (e.g. app/models/physical) and to > separate them by module (e.g. Physical::Projects::Project). > > He also evangelizes Postgresql instead of MySQL, and suggests not > using migrations at all but using raw SQL to create the tables, > because he recommends that you NOT treat the database like a dumb data > store (something the rest of the Rails community seems to do and be > okay with) and make good use of check constraints, triggers, > referential integrity and the like at both the database level AND the > application level. He is against migrations because of the extremely > limited subset of SQL they allow for (i.e. no real constraints). > > Now, I come from a C# background so this stuff makes sense to me, but > at the same time I want to follow the best practices from the Rails > world where I'm looking to redefine myself. I agree with a lot of > what Mr. Chak says about organization, since the one major fault I > find with Rails is that it doesn't lend itself to organizing your > application like other frameworks (e.g. Django); for example if my > application contains 2 major parts (say a Blog application and a > Network application), Rails just smushes them both together under the > app directory, and their models/views/controllers are all kept > together instead of being separated (e.g. app/models/blog/, app/models/ > social). The problem with using the approach from Enterprise Rails is > that it pretty much means I cannot use the generators, unless I were > to redefine them to follow the "enterprise" structure. While that's > not a big deal, I can't help but think that I would be going "against > the grain" as far as my application is concerned - call me a bandwagon > jumper, but I always prefer to follow the community when it comes to > programming, instead of going off on my own. > > From reading the book, though, I can't seem to understand why the > Rails community has never done this from the start. Rails > applications are meant to be scalable, no? And the big ones have got > to scale if they get successful, right? The Rails app that Dan Chak > worked on, according to what he says in the book, ballooned to some > 188 classes; if other large Rails apps are like that, how do they > manage? > > Basically - I'm wondering if I should be following the advice in the > book from the get-go when I design my application, or if I should > follow the best practices of the Rails community and not worry about > the "enterprise" stuff until I need to (at which point it may or may > not be too late). Also remember that I am fairly new to Rails but I > still want to do things the "right" way. > > Any insight from experienced Rails developers would be appreciated - > when I started reading the book I couldn't believe that these things > are NOT done in the Rails world, because they seem like common sense > to me that any professional developer would do, and yet almost all of > the Rails people I've read about and talked to consider them to be > inconsequential. Maybe my vision is just skewed, coming from the > Microsoft world. --~--~-~--~~~---~--~~ 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: ApplicationController: understanding generate scaffold
On Mon, Dec 29, 2008 at 12:13 PM, Sarah Allen < rails-mailing-l...@andreas-s.net> wrote: > > I'm new to Rails and I'm trying to understand the code created by > generate scaffold. I'm using Rails 2.2.2. > > $ ./script/generate scaffold Task description:string > > generated the following code in app/controller/tasks_controller.rb > > class TasksController < ApplicationController > # GET /tasks > # GET /tasks.xml > def index >@tasks = Task.find(:all) > >respond_to do |format| > format.html # index.html.erb > format.xml { render :xml => @tasks } >end > end > > # GET /tasks/1 > # GET /tasks/1.xml > def show >@task = Task.find(params[:id]) > >respond_to do |format| > format.html # show.html.erb > format.xml { render :xml => @task } >end > end > > # GET /tasks/new > # GET /tasks/new.xml > def new >@task = Task.new > >respond_to do |format| > format.html # new.html.erb > format.xml { render :xml => @task } >end > end > > # GET /tasks/1/edit > def edit >@task = Task.find(params[:id]) > end > > I noticed that the edit method is missing some code. If I remove those > same lines from each of the methods above. The code still works, why? > > I couldn't find ApplicationController in the API docs at > http://api.rubyonrails.org/ ... I figured the behavior must be defined > in the super class, but I can't seem to find the code for it either. > > Can someone point me in the right direction to illuminate this mystery? > > Thanks in advance, > Sarah > Try creating a task, and then editing it. You should find that, when you remove the lines from "Edit", you don't get information that you previously entered when you created the task. If you look in app/controllers/application.rb, you will find that ApplicationController is a task that you derived from ActionController::Base. You should be able to find documentation about ActionController::Base at http://api.rubyonrails.org/ >From one newbie to another... Look at the links created in the index view for your tasks controller. With the default scaffold, you should see three links to the right of each task listed: Show, Edit, and Destroy. If you mouse-over the Edit link, you will probably see something that looks like: http://localhost:3000/tasks/1/edit. That says to the routing system in Rails (through the magic of the code you wrote in config/routes.rb) "Invoke the 'edit' action in the 'tasks' controller, and, by the way, set the 'id' parameter to '1'". When your #edit action is invoked, it searches the Task table in your database for the entry with an ID of 1. Then Rails, by default, will render a view (a web page) named "edit". You can see the template for that web page in app/views/edit.html.erb. If you completely remove the #edit action, the default behavior is still to render a template with the same name as the action. If you leave the #edit action in there, but don't do anything in it, the default behavior is still to render a template with the same name as the action. If you leave the code in there as written, the #edit action will fetch the row from the Task database with the specified ID. The #edit view will then have some data to show when it displays the form. --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] attachment_fu and mysql (server has gone away)
I have a problem with my hosting "hostgator" In my site i have a section for photos upload. For manage it i use attachment_fu. In the action of upload i do some simple query. If the file to upload is smaller than 1mb there isnt any problem but if it is bigger than 1 mb about i receive an error: mysql error server has gone away. i wrote to hostgator. they responsed me with: All MySQL connections open for more than 15 seconds are killed off once a minute. Your script needs to be modified so the MySQL connection is opened just prior to the query actually being run How i can to open mysql connection only when i do query for this action? thanks -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: ApplicationController: understanding generate scaffold
The respond_to block is optional, and if the block is missing rails will execute a render :task so for the edit task it will look for the / controller/edit.html.erb file Here is information from the api... http://apidock.com/rails/ActionController/MimeResponds/InstanceMethods/respond_to On Dec 29, 9:13 am, Sarah Allen wrote: > I'm new to Rails and I'm trying to understand the code created by > generate scaffold. I'm using Rails 2.2.2. > > $ ./script/generate scaffold Task description:string > > generated the following code in app/controller/tasks_controller.rb > > class TasksController < ApplicationController > # GET /tasks > # GET /tasks.xml > def index > @tasks = Task.find(:all) > > respond_to do |format| > format.html # index.html.erb > format.xml { render :xml => @tasks } > end > end > > # GET /tasks/1 > # GET /tasks/1.xml > def show > @task = Task.find(params[:id]) > > respond_to do |format| > format.html # show.html.erb > format.xml { render :xml => @task } > end > end > > # GET /tasks/new > # GET /tasks/new.xml > def new > @task = Task.new > > respond_to do |format| > format.html # new.html.erb > format.xml { render :xml => @task } > end > end > > # GET /tasks/1/edit > def edit > @task = Task.find(params[:id]) > end > > I noticed that the edit method is missing some code. If I remove those > same lines from each of the methods above. The code still works, why? > > I couldn't find ApplicationController in the API docs > athttp://api.rubyonrails.org/... I figured the behavior must be defined > in the super class, but I can't seem to find the code for it either. > > Can someone point me in the right direction to illuminate this mystery? > > Thanks in advance, > Sarah > > http://www.ultrasaurus.com/code(where I'm keeping a journal of my > learning Rails so far)http://www.ultrasaurus.com(primary blog) > -- > 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: will_paginate working in the opposite way expected
Frederick Cheung wrote: > On 27 Dec 2008, at 18:38, Fernando Perez wrote: > >> could >> I be doing wrong? > > As in Next fetches older posts ? If so you're not doing anything > wrong. While you may thing of next as more recents posts, > will_paginate only cares about it being the next page. > You can tell will_paginate what labels to use for the links with > the :next_label/:previous_label options so you can swap them around or > use something less ambiguous like older/newer > > Fred Ok I get it Frederick, so everything is working fine, it's just the name that mixed me up. Thanks. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] ApplicationController: understanding generate scaffold
I'm new to Rails and I'm trying to understand the code created by generate scaffold. I'm using Rails 2.2.2. $ ./script/generate scaffold Task description:string generated the following code in app/controller/tasks_controller.rb class TasksController < ApplicationController # GET /tasks # GET /tasks.xml def index @tasks = Task.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @tasks } end end # GET /tasks/1 # GET /tasks/1.xml def show @task = Task.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @task } end end # GET /tasks/new # GET /tasks/new.xml def new @task = Task.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @task } end end # GET /tasks/1/edit def edit @task = Task.find(params[:id]) end I noticed that the edit method is missing some code. If I remove those same lines from each of the methods above. The code still works, why? I couldn't find ApplicationController in the API docs at http://api.rubyonrails.org/ ... I figured the behavior must be defined in the super class, but I can't seem to find the code for it either. Can someone point me in the right direction to illuminate this mystery? Thanks in advance, Sarah http://www.ultrasaurus.com/code (where I'm keeping a journal of my learning Rails so far) http://www.ultrasaurus.com (primary blog) -- 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: Preventing a form from submitting on ENTER
Ivor Paul wrote: > How about removing form tags - just have the field and the observe_field > this might not be valid html - not sure about that. http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";> http://www.w3.org/1999/xhtml"; xml:lang="en"> untitled Test The above code passes the W3C validator for XHTML 1.0 Strict and XHTML 1.1. Notice that the surrounding the and was necessary to pass XHTML Strict, but was not required for XHTML 1.0 Transitional. Other surrounding tags besides work as well, but the and tags must be contained by something. Example (this is INVALID!): -- http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";> http://www.w3.org/1999/xhtml"; xml:lang="en"> untitled Test W3C Validator: Line 10, Column 19: document type does not allow element "label" here; missing one of "ins", "del", "h1", "h2", "h3", "h4", "h5", "h6", "p", "div", "address", "fieldset" start-tag. -- -- 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: index => nil params jumbled *sometimes*
On Dec 29, 10:41 am, MaD wrote: > > - If I login as the user, I can't seem to reproduce the error, but > > this happens constantly for this one guy, on these three Jobs. Ugh. > > this sucks. but i think as long as you can't reproduce the error, you > porbably won't be able to fix it. I can't reproduce it, but I can see the effect. Everything seems to be in place and the snag is that the params is jumbled. I'm not doing anything against Rails' opinion ;( hrm. --~--~-~--~~~---~--~~ 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: 2.2.2 simple_captcha upgrade error
I asked my boss what gem it was he determined we need to be on, he claims "pr", so I tried to install it and it fails to compile, so now im back to square one. I really thought I had this all sorted out a few weeks ago, maybe it was on a different computer. On Dec 28, 11:18 pm, Andrew Bloom wrote: > It's not the postgres (psql) version thats the problem, its actually > the ruby postgres gem that ActiveRecord uses to connect to psql. I > will be in the office tomorrow and will check it out. > > On Dec 28, 10:48 am, Richard Schneeman > s.net> wrote: > > That does make sense given all i've read about this error, thanks a > > bunch!! I'm not in too much of a hurry to play wih 2.2.2, if its not too > > much trouble whenever you get back to the office, could you let me know > > what version of pgsql worked for you ( so i'm not just shooting in the > > dark) ? > > > Right now i'm running 8.3.3 and if memory serves me correctly i had too > > much trouble directly installing the gem, so I used mac ports. I tried > > installing 8.2 from ports and wasn't able to, i'm assuming whatever > > version i end up with, i'll have completely uninstall 8.3.3 first if i'm > > using ports ? > > -- > > 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: expires_in with fragment-caching
If you are using rails 2.1 && memcached, then you can do this : <% cache(key, :expires_in => 5.minutes) do %> hello, world <% end %> On Dec 29, 7:18 pm, sigma wrote: > Hi all > > Is it posible do have a expires_in with fragment-caching? Does this > work with memcached? > > Thank you for your aswers! > > Chris --~--~-~--~~~---~--~~ 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: expires_in with fragment-caching
Chris, 1. If you are running rails 2.1 && memcached then you can do this in fragment caching: <% cache(key, :expires_in => 5.minutes) do %> hello, world! <% end %> - Gautam On Dec 29, 7:18 pm, sigma wrote: > Hi all > > Is it posible do have a expires_in with fragment-caching? Does this > work with memcached? > > Thank you for your aswers! > > Chris --~--~-~--~~~---~--~~ 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: index => nil params jumbled *sometimes*
> - If I login as the user, I can't seem to reproduce the error, but > this happens constantly for this one guy, on these three Jobs. Ugh. this sucks. but i think as long as you can't reproduce the error, you porbably won't be able to fix it. --~--~-~--~~~---~--~~ 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: index => nil params jumbled *sometimes*
> honestly: this seems strange. some points to start looking for an > answer: > - are you able to reproduce the error, if you login as that user? > - what about that user? does he have any 'special qualities' (like: > has special rights or uses lynx to access the site *g*)? > - does your session variable contain the correct data? It sure does ;) - If I login as the user, I can't seem to reproduce the error, but this happens constantly for this one guy, on these three Jobs. Ugh. - The user is just a standard User, no awesome Admin qualities, and he uses IE7 against my better judgment - The session[:timesheet_user].id is correct (and correctly set in the params hash) - A TimeCard with a blank ID means that it is new (and not yet saved). --~--~-~--~~~---~--~~ 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] SQL tool
Hi, I'm looking for a tools under windows that can draw a SQL map using a sql file and ruby convention. So relations are kept and I can get a nice gif or jpeg file with my DB schema. Thanks :-) -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Your thoughts on "Enterprise Rails"
> Firstly, he advocates you organize your application deeper than the > default Rails skeleton; for example he says to put all of your models > under a "physical" directory (e.g. app/models/physical) and to > separate them by module (e.g. Physical::Projects::Project). I would agree that organizing deeper can be useful. But if so, the groups should be meaningful to your application, not arbitrary (which from your account "physical" seems to be). Smaller Rails applications don't do it, not because of any bias against it, but because they don't have 188 models to organize. 10 to 30 models is not hard to manage. And while generally it makes sense to keep everything in one application, keep in mind that it is possible to have more than one application and still share a table, a model or pass data between them. Depending on the schema and requirements, a 188 model application might be happier as three 60 model applications that share a User model/table. To give a non-Rails example: Google needs to keep track of my login, but that doesn't mean Google Maps and Gmail have to be one application. > He also evangelizes Postgresql instead of MySQL I would say that's his personal preference and not gospel. MySQL, Oracle, SQLite and other flavors have their fans too. Do your own research as to which one is right for you. > He is against migrations because of the extremely > limited subset of SQL they allow for (i.e. no real constraints). Whatever your opinion about database constraints vs. application constraints, he obviously does not realize that migrations allow you to execute any SQL. > The problem with using the approach from Enterprise Rails is > that it pretty much means I cannot use the generators, unless I were > to redefine them to follow the "enterprise" structure. Generators are there to help 90% of the time. The other 10% you'll have to do by hand, modify what they give you or roll your own. Once you get the hang of it, you'll see that it will only take a minute or two longer to do it without generators. Don't let this be a major concern. > Basically - I'm wondering if I should be following the advice in the > book from the get-go when I design my application, or if I should > follow the best practices of the Rails community and not worry about > the "enterprise" stuff until I need to (at which point it may or may > not be too late). Also remember that I am fairly new to Rails but I > still want to do things the "right" way. I think a good rule of thumb in programming is not to build it until you need it. Otherwise you will spend a considerable amount of time maintaining code and keeping options open for the future that you may never use. It is not hard to implement the "enterprise recommendations" you mentioned (grouping controllers and models, upgrading databases, etc.) when you find you need them. Don't burden yourself with them until you do. Ideally a framework will allow you to build your application fast, not burden you with features you may never use, but still keep your options for feature modifications and application scalability open for the future. I think Rails does that well. Kevin --~--~-~--~~~---~--~~ 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: add an editor on my application
Hi I have limited experience with FCKEditor -- http://www.fckeditor.net/ and slightly more exp with tinymce -- http://tinymce.moxiecode.com/ but in my experience the better solution is to use textile -> http://redcloth.org/ & http://wiki.rubyonrails.org/rails/pages/RedClothsince they are simpler and then harder for users to break. TinyMCE imho gives the user to many options and since most people are not good with layout they often make a bigger mess than if you gave them something like redcloth/textile Regards On Mon, Dec 29, 2008 at 11:52 AM, Johny ben < rails-mailing-l...@andreas-s.net> wrote: > > Does anyone have a good suggestion for the best editor that can I embed > on my application.. > -- > 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: index => nil params jumbled *sometimes*
as rendering the view seems ok, i suppose it has something to do with the logic behind it. so far your posted params show, that your controller receives the second entry as first parameter, the first entry gets split by the third, which is not yet saved or the id got lost. additionally: all this only happens for one user. honestly: this seems strange. some points to start looking for an answer: - are you able to reproduce the error, if you login as that user? - what about that user? does he have any 'special qualities' (like: has special rights or uses lynx to access the site *g*)? - does your session variable contain the correct data? --~--~-~--~~~---~--~~ 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: Finding Child Records Efficiently
On Dec 28, 8:07 pm, Mark Reginald James wrote: > One alternative is to make the ancestor array a string key > to each record ("abe|homer|bart"), allowing instant retrieval. This seems like a relatively good idea, could have a string-key called family_tree or something and just do find_by_family_tree("abe|homer| bart") This doesn't quite feel right - it seems like the only info you should need to keep is a person's parent (from which you can then find their parent and so forth). It might also lead to some very long strings eventually! > > Another would be to build the sql iteratively: > This is what I'm doing at the moment - I'm using the "betternestedset" plugin, so have access to a "children" method that returns an arrary of children. Will this have all been pre-fetched efficiently? And if so, is the iterative code the way to do it? tree = ["abe","homer","bart"] person = Person.find_by_name(tree[0]) if tree.size > 1 1.upto(tree.size - 1) do |i| person = person.children.find { |child| child.name == tree [i] } end end @person = person Thanks for the help, DAZ --~--~-~--~~~---~--~~ 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: index => nil params jumbled *sometimes*
On Dec 29, 9:50 am, MaD wrote: > did you check if it is rendered correctly? whats your html output for > that code? Yep, it renders correctly (below); as noted, it works for all but one user... J080183 - Dynamix Office 855 Grandview J080181 - CCC Westlake Phase 1 Building ... Bereavement Vacation ... --~--~-~--~~~---~--~~ 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: index => nil params jumbled *sometimes*
did you check if it is rendered correctly? whats your html output for that code? --~--~-~--~~~---~--~~ 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: Your thoughts on "Enterprise Rails"
Basically from reading the book, Dan doesn't believe in the "Rails Way" because he hints that it lends itself to quick and dirty code; not dirty in the sense of old PHP/ASP code, but dirty in that it doesn't care about scalability from the start but as an afterthought. Although his book does seem more geared towards using Rails in an enterprise environment, as opposed to the usual new startup. He does mention that, as a developer of an original "big Rails site" he's speaking from hindsight in his own projects and that he would architect them properly to scale from the start. --~--~-~--~~~---~--~~ 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: A CSS issue
Box models here's a handy IE toolbar -- Internet Explorer Developer Toolbar http://www.microsoft.com/downloadS/details.aspx?familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en I don't consider myself a guru. In looking at your CSS there could be a lot of cleaning up done. Example. you declare font-family in many places. You could make a "main.css" and do -- body { font-family: Geneva, Arial, Helvetica, sans-serif; font-size: medium; } -- That way your fonts are the same and since you're declaring it once less to download. You could go further and make a "type_001.css" and just declare all your typography in it. When you want to change you font change the file to say "type_002.css" that way the cached css won't be pulled and you wonder why the type hasn't changed. You could do the same for: reset (http://meyerweb.com/eric/tools/css/reset/) layout (positioning) style (colors and other eye candy) my 2 cents John On Dec 29, 4:01 am, Fernando Perez wrote: > MaD wrote: > > personallly i use > > transparent borders instead of padding/margin, when i encounter such a > > problem. > > That's an excellent piece of advice, and it is what I also use, but it > doesn't work all the time if there is a special background. Another > problem are floating elements, try switching them from left to right and > switch the order they appear in the html, sometimes it will avoid IE > adding a double margin. > -- > 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] expires_in with fragment-caching
Hi all Is it posible do have a expires_in with fragment-caching? Does this work with memcached? Thank you for your aswers! Chris --~--~-~--~~~---~--~~ 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: Passing a collection to a form partial
right.. thanks. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] index => nil params jumbled *sometimes*
My app has a timesheet, which is a collection of many TimeCards, based on a Date. I have one user that can create new TimeCards just fine, except on three associated Jobs. Each time he saves he gets a 500 error. Looking at the params, they come across jumbled and my processing method chokes: (The first "time_cards" entry is correct, the second is split by the third) Parameters: { "date"=>"2008-12-17", "time_cards"=>[ { "job_id"=>"3107", "time_card_entry_type"=>"Field", "time_card_date"=>"2008-12-17", "id"=>"285875", "note"=>"Akron e-rate cable project counts/ FSR presentation", "hours"=>"2", "user_id"=>"178" }, { "time_card_date"=>"2008-12-17", "id"=>"285774", "user_id"=>"178" }, { "job_id"=>"3089", "time_card_entry_type"=>"Field", "time_card_date"=>"2008-12-17", "id"=>"", "note"=>"progress drawing and spec revision", "hours"=>"2.5", "user_id"=>"178" }, { "job_id"=>"3107", "time_card_entry_type"=>"Field", "note"=>"Akron e-rate cable project counts", "hours"=>"2" } ] } The form is a partial that uses index => nil, and it works for all other users, except this guy, on these associated Jobs. %tr.entry - fields_for "time_cards[]", entry, :index => nil do |entry_form| = entry_form.hidden_field(:time_card_date, :value => @date) = entry_form.hidden_field(:user_id, :value => session [:timesheet_user].id) = entry_form.hidden_field(:id) %td= entry_form.select :job_id, available_jobs %td= entry_form.select :time_card_entry_type, allowable_types %td= entry_form.text_field :hours, :size => 5 %td= entry_form.text_field :note I've scratched my head on this one for weeks, anything look out of order? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: [OT] Re: [Rails] Advice on Mac versus PC ?
On Friday 26 December 2008 06:52 am, Peter De Berdt wrote: > > On 26 Dec 2008, at 12:33, Matt Harrison wrote: > > >> I have a HP laptop that is not quite 3 years old. I've downloaded > >> alot of stuff, and the machine seems to run alot slower than it used > >> to. It takes along time to boot, and it's gotten really bad, though I > >> do have AVG. > > > > Backup, format and re-install windows. Every computer needs this now > > and > > again. I do that to my desktop about every 3 months, keeps it running > > like new, plus you'll have the experience for when a hard-disk dies. > > You gotta be kidding. I did it about every 6 months on my regularly used (Windows) computers--this was back in the day when I used Windows 95 and 98. It definitely was required for Windows and/or the mix of applications I used. To the OP: I think you know that PCs today can run Linux (just has to be installed unless you find a pre-installed version), and then, with Linux installed, I wouldn't expect a Mac with Linux to be any better than a PC with Linux (with the possible exception of some different applications available). Randy Kramer -- I didn't have time to write a short letter, so I created a video instead.--with apologies to Cicero, et.al. --~--~-~--~~~---~--~~ 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: Preventing a form from submitting on ENTER
How about removing form tags - just have the field and the observe_field this might not be valid html - not sure about that. Ivor On Mon, Dec 29, 2008 at 12:21 PM, sa 125 wrote: > > Hi - I have the following problem: my app has a form that acts as a > filter to a table on the page, so that the user can search any value in > the table (via text box) or use select lists for more specific search. > The form is being observed by an observe_form helper that runs every 1-2 > seconds or so. It's all still in testing. > > I noticed that when I hit return while in the textbox, the form posts > and redirects me to an action unknown page. I want to remove that > functionality so that hitting enter wont do anything -- any idea how to > do it? > > Thanks > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Passing a collection to a form partial
On Mon, Dec 29, 2008 at 2:37 PM, sa 125 wrote: > > I'm trying to create an editable table by rendering a partial containing > a form. > > In the index: > > > <%= render :partial => 'product_edit', :collection => @products %> > > I'm getting an error 'undefined local variable or method `product`..' The name of the local variable is the name of the partial, which is product_edit in this case. --~--~-~--~~~---~--~~ 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: Installing Plugins Offline?
On Mon, Dec 29, 2008 at 12:58 AM, Frederick Cheung wrote: > > > > On Dec 29, 8:28 am, sa 125 wrote: >> How would I go about installing rails plugins offline? I cannot connect >> to the web on my work computer, though I have a dedicated internet >> machine for downloads and such. >> > > Installing plugins just copies them to vendor/plugins, so if you can > download them elsewhere you should be fine. > This isn't entirely accurate. There are some install scripts that can be run when the plugin includes them. (for example, setting up some config files for you) For example, look at the following plugin (one our customers use for deployment for http://railsboxcar.com/ ) http://github.com/planetargon/boxcar-conductor/tree/master You'll see in the README that there is a command to run script/runner install.rb if you're doing manually. So, if you are doing it manually, make sure to check for an install.rb (or uninstall if you're removing a plugin) Cheers, Robby -- Robby Russell Chief Evangelist, Partner PLANET ARGON, LLC design // development // hosting w/Ruby on Rails http://www.planetargon.com/ http://www.robbyonrails.com/ aim: planetargon +1 503 445 2457 +1 877 55 ARGON [toll free] +1 815 642 4068 [fax] --~--~-~--~~~---~--~~ 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] Passing a collection to a form partial
I'm trying to create an editable table by rendering a partial containing a form. In the index: <%= render :partial => 'product_edit', :collection => @products %> In the partial: <% form_for :product do |f| %> <%= f.text_field :name %> <%= f.select :in_stock, [['YES','true'],['NO','false']] %> <% end %> I'm getting an error 'undefined local variable or method `product`..' What am I doing wrong? -- 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: Failing to render RJS
You need to rename it to index.js.rjs. Check in firebug then if you get response. --~--~-~--~~~---~--~~ 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: Question about "partial controllers" sub-applicaktions
http://m.onkey.org/2007/12/9/namespaced-models seems to be talking about same problems. You might wanna read it. --~--~-~--~~~---~--~~ 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: One layout for entire apps
You can also change the layout by calling layout 'layout' from the controller class. Joshua Partogi napísal(a): > Dear all, > > I am still new in rails, and I realised that in rails each model has > its own layout/template located under layouts/ > > Now my question is, is it possible to have only one layout for the > entire apps instead of having separate one for each model? If so, is > there any guide I can read about it? Or could someone give me a hint > on how to do it > > Thanks in advance --~--~-~--~~~---~--~~ 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 get select_tag value in controller?
I suppose you're using prototype, so you just need to get the value of the select box. $("id-of-the-element").getValue() On 28. Dec., 15:04 h., Zhao Yi wrote: > Frederick Cheung wrote: > > You have to tell remote function what to submit, it's not going to > > guess for you. > > This is what the :with option for remote_function is for. Check the > > docs for link_to_remote for some examples, I've got some extra ones at > >http://www.spacevatican.org/2008/5/17/with-or-without-you-link_to_rem... > > too > > > Fred > > If I added :with in the select_tag: > > :with=>"'project_selection=+'XXX" > > what's value should I use for the current selection? > -- > 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: One layout for entire apps
Thank you all for the responses. I'm going to try it out first. Cheers On Dec 29, 3:27 am, "Robby Russell" wrote: > On Sun, Dec 28, 2008 at 4:40 AM, Joshua Partogi wrote: > > > Dear all, > > > I am still new in rails, and I realised that in rails each model has > > its own layout/template located under layouts/ > > > Now my question is, is it possible to have only one layout for the > > entire apps instead of having separate one for each model? If so, is > > there any guide I can read about it? Or could someone give me a hint > > on how to do it > > > Thanks in advance > > Joshua, > > By default, Ruby on Rails will attempt to render the following layout view. > > * /app/views/layouts/application.html.erb > > This would match the ApplicationController naming. > > Good luck! --~--~-~--~~~---~--~~ 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: NameError: uninitialized constant Digest::SHA2
Just try the echo statement and check what it is printing in the model.May be the sha1 will be using Time.now function also in addtion to its own coding.The time that value is authenticated and the time when u are checking the authentication will be different The solution is if the sha1 is encoded with time also just remove the Time.now function from it.Then this will solve the issue.i have also faced the similar problem when i used acts_as_authenticated plugin. On Dec 28, 1:08 am, Sav wrote: > Ouch - I simply used Digest::SHA256 instead of Digest::SHA2 and it > works now. > > On Dec 27, 8:44 am, Sav wrote: > > > I'm migrating a working app to a new server, but all my authentication > > tests are failing on SHA2. The user.rb model has require 'digest/ > > sha2' at the top, yet I still get this error... > > > NameError: uninitialized constant Digest::SHA2 > > > Any ideas how to resolve this issue? I've been searching Google for a > > day and haven't found anything. > > > Here is some more info on my new setup (running Debian etch)... > > > # ruby -v > > ruby 1.8.5 (2006-08-25) [i486-linux] > > > # rails -v > > Rails 2.2.2 > > > # gem -v > > 1.3.1 > > > # gem list --local > > > *** LOCAL GEMS *** > > > actionmailer (2.2.2, 2.0.2) > > actionpack (2.2.2, 2.0.2) > > activerecord (2.2.2, 2.0.2) > > activeresource (2.2.2, 2.0.2) > > activesupport (2.2.2, 2.0.2) > > cgi_multipart_eof_fix (2.5.0) > > daemons (1.0.10) > > fastthread (1.0.1) > > gem_plugin (0.2.3) > > hoe (1.8.2) > > jruby-openssl (0.3) > > memcache-client (1.5.0) > > mongrel (1.1.5) > > mongrel_cluster (1.0.5) > > rails (2.2.2, 2.0.2) > > rake (0.8.3) > > ruby-openid (2.1.2) > > rubyforge (1.0.1) > > youtube-g (0.4.9.9) > > ZenTest (3.11.0) --~--~-~--~~~---~--~~ 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] Dont cache a variable in action
Hi I m facing a unique problem. I have a method which i m caching through caches_action but in that i have one variable which i dont want to cache.. To be specific i m using paging and if i cache the page my pagination stops. I m using custom pagination method. Can ne one tell me how to solve this issue. Is there a way i can make it possible not to cache one variable in a method. Sounds odd but I dont have ne other option in my mind Thanks -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: RailsXls Plugin Not Working
I Used Spreadsheet-excel gem to generate excel reports.The problem of dependencies is not there.It worked perfectly fine But anyway i want to know Why RailsXLS Plugin Not worked On Dec 27, 8:15 pm, karthik wrote: > Hi, > > I am using RailsXls Plugin to generate Excel Reports > > I am using Rails 2.1.2 Version > > I Have installed Jdk 1.5 Also > > I am getting this error when i am trying to start my webrick server > > rails/activesupport/lib/active_support/dependencies.rb:493:in > `const_missing': uninitialized constant in Rails::Plugin::Worksheet > > Please guide me in this issue > > Rgds, > Karthikeyan.R --~--~-~--~~~---~--~~ 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: Your thoughts on "Enterprise Rails"
Hello Wayne, Wayne Molina schrieb: > for example if my > application contains 2 major parts (say a Blog application and a > Network application), Rails just smushes them both together under the > app directory, and their models/views/controllers are all kept > together instead of being separated (e.g. app/models/blog/, app/models/ > social). that's the same question I asked a few days ago (http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/8734eb42b922efec/) Unfortunately I haven't got an answer. But reading the answers here in this thread let me think that splitting the apps isn't the "rails way". But I'm still uncertain whether the rails way makes sense to me or not ;-) Maybe I'll have to read Dan's book. Martin --~--~-~--~~~---~--~~ 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: Newbie Join-Model Misery
Perfect! Works like a charm! A big thanks to all! If anyone is interested the finished app can be downloaded from: http://github.com/aglasspool/rubygrade/tree/master or there is an online demo at http://rubygrade.heroku.com Thanks again! -- 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: Rails Migration Question
instead of just looking for someone that is willing to implement your models and methods, why don't you just give it a try first and ask if you encounter any problems? start by defining the relations between models (has_many, belongs_to, ...). add callbacks (after_save :convert_price) and methods (def convert_price). all along write some tests to see if your code is working correctly. if you're stuck somewhere, come back and ask for help. --~--~-~--~~~---~--~~ 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 Migration Question
Can anyone help me in this: Given the following database migration: class DefineDatabase < ActiveRecord::Migration def self.up create_table "products" do |t| t.column "name", :string t.column "price_converted", :integer # NOTE: we shouldn't store monetary values as floats to avoid rounding errors end create_table "categories" do |t| t.column "name", :string end create_table "categories_products" do |t| t.column "product_id", :integer, :null=>false t.column "category_id", :integer, :null=>false t.column "display_order", :integer, :default=>0, :null=>false end end def self.down drop_table "products" drop_table "categories" drop_table "categories_products" end end I need to implement model classes named Category and Product so that the following code example generates the expected output: cat1 = Category.new(:name=>'Books') cat1.save p1 = cat1.products.create(:name=>'My first book', :price=>10.99 ) puts p1.price_converted # should be the price in cents, that is x 100 and rounded up to next whole number >> 1099 p2 = cat1.products.create(:name=>'My second book', :price=>20.95 ) puts p2.price_converted >> 2095 cat1.set_display_order(p1, 1) # this should set the 'display_order' column associated with the product p1 to 1 prod_array = cat1.products.find(:all, :order=>'display_order, price') puts prod_array[0].name >> My second book puts prod_array[1].name >> My first book -- 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] Preventing a form from submitting on ENTER
Hi - I have the following problem: my app has a form that acts as a filter to a table on the page, so that the user can search any value in the table (via text box) or use select lists for more specific search. The form is being observed by an observe_form helper that runs every 1-2 seconds or so. It's all still in testing. I noticed that when I hit return while in the textbox, the form posts and redirects me to an action unknown page. I want to remove that functionality so that hitting enter wont do anything -- any idea how to do it? Thanks -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Restful authentication refactoring
I also noticed that "strange" redundancy, and refactored it the same way you did. -- 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: A CSS issue
MaD wrote: > personallly i use > transparent borders instead of padding/margin, when i encounter such a > problem. That's an excellent piece of advice, and it is what I also use, but it doesn't work all the time if there is a special background. Another problem are floating elements, try switching them from left to right and switch the order they appear in the html, sometimes it will avoid IE adding a double margin. -- 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] add an editor on my application
Does anyone have a good suggestion for the best editor that can I embed on my application.. -- 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: Installing Plugins Offline?
I thought so, just wanted to confirm. Thanks! -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Failing to render RJS
On 29 Dec 2008, at 08:42, Adam Thorsen wrote: > > My code looks like the following, but for some reason the rjs template > (index.js.erb) is not being rendered. I've also tried naming the rjs > file index.js.rjs with no luck. > What does the thing making the request look like ?(index.js.erb will never work, since it will just try and pass that file through erb even though that file isn't an erb template at all) Fred > home_controller.rb: > > def index > respond_to do |format| >format.js >format.html > end > end > > index.js.erb: > > page << "var data = 'Core > Selectors,Attributes,Traversing,Manipulation'.split(',');" > page << "$('#example').autocomplete(data);" > > How does rails decide when to render an rjs file in addition to an > html > file? > -- > 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: A CSS issue
Excellent, thanks for all the help guys. --~--~-~--~~~---~--~~ 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: Installing Plugins Offline?
On Dec 29, 8:28 am, sa 125 wrote: > How would I go about installing rails plugins offline? I cannot connect > to the web on my work computer, though I have a dedicated internet > machine for downloads and such. > Installing plugins just copies them to vendor/plugins, so if you can download them elsewhere you should be fine. Fred > Thanks > -- > 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] (Jobs): Looking for Ruby on Rails programmers and Testers for Milan, Italy and India projects
Blackbirds, italian IT consultancy is looking for IT consultants with at least 2 years of experience on framework Ruby on Rails, Python, SQL, Javascript for a project in Milan, Italy and India starting on February 2009. Send the resume to ppil...@blackbirds.it or prajeeshpil...@gmail.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: 2.2.2 simple_captcha upgrade error
how shud we create tooltip in rails application.. Thanks in advance On Mon, Dec 29, 2008 at 11:05 AM, Ryan Bigg wrote: > > Try to install the postgres-pr gem install and use that. > - > Ryan Bigg > Freelancer > http://frozenplague.net > > > > > > > > On 29/12/2008, at 3:48 PM, Andrew Bloom wrote: > > > > > It's not the postgres (psql) version thats the problem, its actually > > the ruby postgres gem that ActiveRecord uses to connect to psql. I > > will be in the office tomorrow and will check it out. > > > > On Dec 28, 10:48 am, Richard Schneeman > s.net> wrote: > >> That does make sense given all i've read about this error, thanks a > >> bunch!! I'm not in too much of a hurry to play wih 2.2.2, if its > >> not too > >> much trouble whenever you get back to the office, could you let me > >> know > >> what version of pgsql worked for you ( so i'm not just shooting in > >> the > >> dark) ? > >> > >> Right now i'm running 8.3.3 and if memory serves me correctly i had > >> too > >> much trouble directly installing the gem, so I used mac ports. I > >> tried > >> installing 8.2 from ports and wasn't able to, i'm assuming whatever > >> version i end up with, i'll have completely uninstall 8.3.3 first > >> if i'm > >> using ports ? > >> -- > >> 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] cannot open ActiveRecord::Migration: No such file
Hi i encounter a problem while running the migration script. ( ie db/migrate/20081229062613_create_posts.rb) . when the command is executed i encounter the following error. "cannot open ActiveRecord::Migration: No such file" followed by a lot of errors indicating the missing of certain files. any solution plz --~--~-~--~~~---~--~~ 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] Failing to render RJS
My code looks like the following, but for some reason the rjs template (index.js.erb) is not being rendered. I've also tried naming the rjs file index.js.rjs with no luck. home_controller.rb: def index respond_to do |format| format.js format.html end end index.js.erb: page << "var data = 'Core Selectors,Attributes,Traversing,Manipulation'.split(',');" page << "$('#example').autocomplete(data);" How does rails decide when to render an rjs file in addition to an html file? -- 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: A CSS issue
in addition to everything that has been said already: - get the firefox-plugins "firebug" and "web-developers toolbar". they are very helpful for creating and validating html- and css-code - for internet-explorer to show your css properly try to use padding and margin as little as possible (google for "IE margin padding" and you will find a lot of people with problems). there are many ways to get this to work, but no generic solution. personallly i use transparent borders instead of padding/margin, when i encounter such a 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: acts_as_versioned and rails 2.2.2
You can get the latest version of acts_as_versioned from Github at http://github.com/technoweenie/acts_as_versioned which will work with dirty objects in Rails 2.1 and later -- 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 -~--~~~~--~~--~--~---