[Rails] radio buttons on edit/update form
Radio buttons in an edit/update form do not display the underlying data (all radio buttons are displayed unchecked) although any changes made through these contols are updated. %= f.radio_button(:sex, 'female', :checked = unchecked) % %= f.radio_button(:sex, 'male', :checked = unchecked) % In this case the column type is a string, however the same problem holds for boolean and integer column types. Anyway, I am missing something integal in the process, but clueless as to what it is. Feedback will be much appreciated. Thanks, Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: radio buttons on edit/update form
Marnen, You are correct. In my copy and paste haste, I had forgot to make the changes. Thank you much. Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: error (nil object) on object creation
Hello Rick and thanks for answering, I'm feeling rather muddled. In my brief ROR history I've been working under the assumption that naming conventions called for controllers to be in the singular. Of course I'm finding out that much has been deprecated. So would you please confirm that controller names are supposed to be plural. Regarding @responder = Responder.new(params[:responder]) Since models and tables are routeless, I'm not clear why routing should be an issue here. And I thought that if the params hash is empty, I will get an empty @responder object which is what I expect in this case. I appreciate any further help you can offer. Cheers, Bill On Sep 2, 7:11 pm, Rick richard.t.ll...@gmail.com wrote: First, I would expect to see a plural here: class IncidentsController ApplicationController May not seem like much but convention is important here. The :responder that appears in your line: @responder = Responder.new(params[:responder]) would typically be passed in as a field in the url that points to this controller/action. If you run: rake routes you should see a line that contains something like: incident GET /incidents/:responder(.:format) {:controller = incidents, :action = show} and the parameter :responder would have been explicitly set by you (or implicitly by link_to helper method), possibly in the file views/ incidents/index.html.erb. On Sep 2, 7:11 pm, zambezi b.but...@overhydration.org wrote: Greetings, Can anyone shed some light on why the following error is raised? I've depleted my small inventory of ideas. Thanks much. Bill NoMethodError in IncidentController#signup You have a nil object when you didn't expect it! The error occurred while evaluating nil.request RAILS_ROOT: C:/RubyRails/rails_apps/rappEAH C:/RubyRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/mime_responds.rb:114:in `initialize' app/controllers/incident_controller.rb:19:in `new' app/controllers/incident_controller.rb:19:in `signup' -e:3:in `load' -e:3 --- class IncidentController ApplicationController def signup @title = register #following is the offending line @responder = Responder.new(params[:responder]) end end #end class --~--~-~--~~~---~--~~ 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: error (nil object) on object creation
I'm going to vent a bit of frustration here. 1. As fast as I learn something, I learn that it has changed or deprecated. Aaargh! 2. I had a suspicion that the singular/plural convention was a lot of silliness and the changes seem to vindicate this view. 3. REST appears to have good intentions, but is generally too limiting in practice and hence requires workarounds that make swiss cheese of the concept. 4. I am worried that the continuous flux as ROR matures is going to mean a short life expectancy for applications. 5. Documentation is abominable or good documentation is scarce. Frustrations aside I feel much better because you were spot on, Rick D. Responder is a model and qualifying the name resolved the problem. I'm still unclear as to why there was a name clash since there is only one class named Responder whether this namespace or elsewhere. But I greatly appreciate all of the the guidance, help and patience from both Ricks'. A little piece of my sanity is in debt to you. Cheers, Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] error (nil object) on object creation
Greetings, Can anyone shed some light on why the following error is raised? I've depleted my small inventory of ideas. Thanks much. Bill NoMethodError in IncidentController#signup You have a nil object when you didn't expect it! The error occurred while evaluating nil.request RAILS_ROOT: C:/RubyRails/rails_apps/rappEAH C:/RubyRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/mime_responds.rb:114:in `initialize' app/controllers/incident_controller.rb:19:in `new' app/controllers/incident_controller.rb:19:in `signup' -e:3:in `load' -e:3 --- class IncidentController ApplicationController def signup @title = register #following is the offending line @responder = Responder.new(params[:responder]) end end #end class --~--~-~--~~~---~--~~ 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] Rake migration issue
I've encountered a problem running Rake migrations. This is in a fresh database (no prior migrations run). 001_create_incident_users 002_create_incidents Running db:migration resulted in table incident_users being successfully created, but Rake then aborted before migrating/creating the second table. So I then tried the following three permutations to coax a successful migration of the incident table and got the same result each time. Basically an incident_user migration is run (rather than incident) and then the process aborts. The log file didn't have anything further to offer. db:migration db:migration incidents db:migration VERSION=002 (in C:/RubyRails/rails_apps/rappEAHv8) == 2 CreateIncidentUsers: migrating === -- create_table(:incident_users) rake aborted! Mysql::Error: Table 'incident_users' already exists: So I thought I would see if anyone has more of a clue than I do before falling back on the MYSQL command line editor just to get things moving along. Thanks much, Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Rake migration issue
Hello Dhruva and Colin, Thanks much for your responses. I think my latest reply went to Colin's email since it hasn't shown up on the discussion list, so I will recap. I dropped and recreated the db and reran the migrations. Unfortunately to the same end with Rake aborting after the first migration. Don't think it is a migration code issue since I can reverse the migration order and still have the first table created followed by Rake aborting on the 2nd. Cheers, Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Rake migration issue
Hi Dhruva and Colin, Ran Rake again to drop and recreate the db without a specific name reference. As before the db was created, although no errors or protests this time. However subsequently running the migration was deja vue. Below is the migration code. It looks straight forward to me, but if I knew what to look for I wouldn't be here. Cheers, Bill -- class CreateIncidentUsers ActiveRecord::Migration def self.up create_table :incident_user do |t| t.column:incident_user_name, :string, :null = false t.column:position, :string t.column:phone, :string t.column:email, :string, :null = false t.column:hashed_password,:string, :null = false t.column:salt, :string t.column:enabled,:boolean, :default = true, :null = false t.column:last_login_at, :datetime t.timestamps end add_index :incident_user_name end def self.down drop_table :incident_user end end #end migration --~--~-~--~~~---~--~~ 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: Rake migration issue
Hi Colin, I added the table reference for the indexes, reran everything and the migration went through fine. Thank you for spotting the problem and thanks to you and Dhruva for bearing with me. As for my antiquated syntax, there is a lot of that. I appreciate the pointer and assume you mean: t.string :name instead of t.column :name, :string Cheers, Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: controller subfolders and routing
Thank you Sijo and Nicholas, Your much appreciated replies have given me some insight and got me moving again. The RESTful reading recommendation (RailsGuide) is excellent and has shed considerable light on what was a murky subject for me. However, one further question regarding the link_to helper. Since Rails conserves paths (and breaks routes when mapping namespaces), I amended the old style link_to method by adding a forward slash in front of the controller name ('home' to '/home'). %= link_to Home, {:controller ='/home', :action ='index' } % How do I achieve this using the new, improved RESTful helper style? Cheers, Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: controller subfolders and routing
Thanks to Nicholas Henry and Sijo Kg for responding. Having to add the routes to the routes.rb file still seems a cumbersome approach, but so be it. Unfortunately it isn't working as I raise a Routing Error ( No route matches /link with {:method=:get} ) with the following configuration ActionController::Routing::Routes.draw do |map| map.namespace :info do |info| info.resources :citation info.resources :download info.resources :link info.resources :recommendation end # Install the default routes as the lowest priority. map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' end --- class Info::LinkController ApplicationController def index @title = LINKS end end - li%= link_to Links, {:controller ='link', :action ='index' } %/li - --~--~-~--~~~---~--~~ 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] controller subfolders and routing
Greetings folks, I'm looking for some confirmation before I go further astray. I decided to anticipate future growth and rather than use a flat controller directory (app/controllers ) without subfolders , I would try a 'tree' structure with subfolders (app/controllers/admin, app/ controllers/info, etc.). Duh, but I ended up with broken routes. The fix seems to be to add all the necessary permutations of subdirectory routes to the routes.rb file. This of course leads to a fate potentially worse than the basic flat directory. Am I missing something easier and more generic to accommodate the routing for 'tree' directories.? Thanks. Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: instance variable (conrollerview) and RESTful
Hello again Frederick, I took up your suggestion and it was revelatory, though I'm not sure what it reveals. With a view and action named 'display', an exception was NOT raised from the action. With alternative names, the exception was raised as expected. I created another application and got the same results. I'm curious as to whether this behavior is repeatable on someone else's setup. Cheers, Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: instance variable (conrollerview) and RESTful
Hello Colin, I did mean % instead of @ and I did have some identifiable text with each view name version. Just cut out what I thought was extraneous to the post. I looked at the development.log and it is clean. The only differences between the view name versions were the expected time/ session/performance/etc. The thought occurred to me that perhaps the use of duplicate view names was the unlikely problem. I've used 'display' as a view name several times across different folders. But I renamed everything and eliminated this as an issue. So for now I am left with a Ruby on Rails app that just has a quirky bias against 'display' as a view name. There are plenty of alternative naming options and alternatives seem to work. So ultimately not a big deal, though I'll be carrying a niggling suspicion that something will pop up and bite me one day. Thank you much for the replies and support. As I indicated earlier, this forum serves as a sanity safety net that keeps me from doing regrettable things to my computer. If I ever turn up an explanation for the problem I will pass it on. Cheers, Bill On Jun 2, 4:24 am, Colin Law clan...@googlemail.com wrote: 2009/6/1 zambezi b.but...@overhydration.org: Hi to Colin, Jennifer and anyone else, If nothing else, this forum serves as a sanity check. My difficulty arose when I created an application wide template as a container for various views and attempted to pass a title variable to the template. None of my fiddling raised any errors. After reading your replies I went back to my application and sacrificed another hour to Ruby idiosyncracies. Here is what I've done and the results. # within layout/application class LinkController ApplicationController def display @title = title (display) end def index @title = title (index) end def foo @title = title (foo) end end title%= @title %/title --- I created a view named 'display' with the above embedded Ruby and opened it in the browser. The title was BLANK. Next I renamed the view 'index' and opened it in the browser. The title appropriately showed title (index) Then I renamed the view 'foo' and again a BLANK title. I renamed the view back to 'index' and the title reappeared. The above was with a template, so I decided to try the same fun experiment with a standalone view. And things got murkier. Views named 'index' and 'foo' display their titles. Views named 'display' are BLANK. Just on the off chance that Ruby is weirder than I think, I checked the list of reserved words. No conflicts there. I also considered there might be something bizarre about the title tags, so just stuck a variable in the middle of the view body @= @title %/body. This just reproduced the earlier results. I presume you meant %= rather than @= Did you include some fixed identifiable text in each view to check that the correct view is being shown? The possible name conflicts are not so much with Ruby (which would generally give an error of some sort) but with Rails. Have you tried other variable names? This is certainly not a general problem or we would all be falling over it all the time. Have you checked in the log file (/log/development.log) for any errors? So there is the sad story. Help! I suppose I can just test all of my view names to see if they pass muster, but I am really hoping to eventually get to where Ruby is a time saver. Any suggestions and/or comments on the instance variable behavior will be welcomed. Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: instance variable (conrollerview) and RESTful
Hi Frederick, I can't give you a direct answer since the breakpoints in my IDE don't work. Actually I can set them in .rb files, but no response under any conditions. So at the moment I can only verify that the method is being called. I'm not sure if I can set a command line breakpoint. Cheers, Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: instance variable (conrollerview) and RESTful
Hi to Colin, Jennifer and anyone else, If nothing else, this forum serves as a sanity check. My difficulty arose when I created an application wide template as a container for various views and attempted to pass a title variable to the template. None of my fiddling raised any errors. After reading your replies I went back to my application and sacrificed another hour to Ruby idiosyncracies. Here is what I've done and the results. # within layout/application class LinkController ApplicationController def display @title = title (display) end def index @title = title (index) end def foo @title = title (foo) end end title%= @title %/title --- I created a view named 'display' with the above embedded Ruby and opened it in the browser. The title was BLANK. Next I renamed the view 'index' and opened it in the browser. The title appropriately showed title (index) Then I renamed the view 'foo' and again a BLANK title. I renamed the view back to 'index' and the title reappeared. The above was with a template, so I decided to try the same fun experiment with a standalone view. And things got murkier. Views named 'index' and 'foo' display their titles. Views named 'display' are BLANK. Just on the off chance that Ruby is weirder than I think, I checked the list of reserved words. No conflicts there. I also considered there might be something bizarre about the title tags, so just stuck a variable in the middle of the view body @= @title %/body. This just reproduced the earlier results. So there is the sad story. Help! I suppose I can just test all of my view names to see if they pass muster, but I am really hoping to eventually get to where Ruby is a time saver. Any suggestions and/or comments on the instance variable behavior will be welcomed. Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] instance variable (conrollerview) and RESTful
I'm a bit flummoxed by something and hoping someone can offer an explanation. If I create a controller (test) with a RESTfully named method and a view (.../test/index), the value of the instance variable passes to the view. class TestController ApplicationController def index @variable = 'Pass to a view' end end - If I rename the view to (.../test/foo) or some other non-RESTful name and appropriately alter the controller method, the value of the instance variable does not pass. class TestController ApplicationController def foo @variable = 'Pass to a view' end end --- A half dozen inprint and online books seem to dispute my personla experience and suggest that the name of the method and view should be irrelevant. So does anybody have a suggestion as to what is going on? Is my routes.rb file where I need to be looking? Thanks much, Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: triple state radio buttons
A final THANK YOU to all the good folks who took time to reply. Alas, the suggestions were somewhat unpalatable to me, but at least I am not still scouring google thinking I have missed some simple alternative. Sometimes you just can't get there from here. I have finally gone with the three radio button option with first one's value set to nil and the entire group explicitely set to unchecked. So far RFC1866 section 8.1.2.4 hasn't protested about this breach of propriety and forced a switch in the unchecked status - at least not in the half dozen browser flavors I've tested so far. Cheers, Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: case/capitalization of LABEL text
Thank you E. Litwin for bumping me in the right direction. I'm much clearer now. Cheers, Bill On May 13, 6:35 pm, E. Litwin elit...@rocketmail.com wrote: You could call it like this: %= label(:country, :name, USA) % This is the method interface: label(object_name, method, text = nil, options = {}) On May 13, 4:05 pm, zambezi b.but...@overhydration.org wrote: I've noticed that when using the form method Label, that the label text is translated to html with the first character in Upper Case and the remainder of the text string as lower case. %= label(:country, USA) % becomes label for=country_USAUsa/ label I can't find any documentation on this unhelpful behavior. Is there anyway way to override it and keep the text string in proper case. Thanks, Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: triple state radio buttons
Hi Hassan, Do you have any idea of what behavior to expect if I explicitly set each radio button's checked property to unchecked? What will take precedence according to W3C specs (or is this all just another browser war casualty)? %= f.radio_button(:hypotonic_saline, nil, :checked = unchecked) % Thanks, Bill On May 8, 8:58 am, Hassan Schroeder hassan.schroe...@gmail.com wrote: On Thu, May 7, 2009 at 7:03 PM, zambezi b.but...@overhydration.org wrote: ... If I am going to use a three button group configuration, I need to have them all unchecked initially. And as the W3C spec I quoted indicates, you *can't count on that* if you're using HTML. Period. If none are explicitly checked by you, the user agent can check any one it wants as a default. Adding a third button doesn't change that. Perhaps you should explore using something like Flash/Flex for your interface? -- Hassan Schroeder hassan.schroe...@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: triple state radio buttons
Hmmm... I can use a Javascript solution and assume/hope the worlds' browsers are all JS enabled. Or use a non-JS solution and assume/hope the browsers/versions I don't test for will see things the same way. Either way I don't see things degrading nicely. My bias (rational or otherwise) is against Javascript. But if I throw in the towel and go that direction, then I think I would consider creating some sort of checkbox group and use JS to make sure that only one checkbox per group could be selected. Cheers, Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] triple state radio buttons
Can I coax a pair of radio buttons to consistently maintain their triple state functionality (null, true, false)? In others words allow the user to undo a response and return the control to a null state (nothing selected). I hope this isn't coming down to some sort of Javascript workaround. Thanks much. Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: triple state radio buttons
Thanks for the reply, Philip. Dropdown boxes are cumbersome visually and ergonomically for the user and I would rather not go there. If I have a pair of grouped Ruby generated radio buttons, then following are the initial possibilities or states: false - false (in which case presumably a null is returned) false - true (returns a 0) true - false (returns a non-zero) It appears that some ivory towered radio button designer never conceived that a user might click on a radio button group, change their mind and want to undo the click therefore returning to a false- false state. Some languages providing for a user interface have caught on, some haven't. Is it perhaps possible to do this by grouping a couple of checkboxes and set then them up so that the user can select either one or none?? Thanks again, Bill Th On May 7, 2:55 pm, Philip Hallstrom phi...@pjkh.com wrote: Can I coax a pair of radio buttons to consistently maintain their triple state functionality (null, true, false)? In others words allow the user to undo a response and return the control to a null state (nothing selected). I hope this isn't coming down to some sort of Javascript workaround. I don't think so. radio button parameters are either ... passed with a value (if clicked) or ... passed with an empty value or not passed at all (if not clicked) There's no way to distinguish b/n unclicked (which would be your false I assume) and null. Why not turn them into drop downs with blank/true/false as values? --~--~-~--~~~---~--~~ 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: triple state radio buttons
I appreciate the answers and help. So I added a third radio button to the group. Remember that what I need is a three state situation (null, true, false). This of course effectively gives me a quadruple state. So I set the third radio button's value to NIL which gets me back to a three state situation.. Now let me provide a little background. This is being used for a lengthy questionnaire (there are 50+ sets of questions). In short, part of good questionnaire design requires that the design doesn't bias the respondant to particular answers. So I don't want the radio button group to show a default value. It potentially confuses respondants and may bias their input. However with the above configuration (the third radio button value of NIL), this becomes the default value and is diplayed to user as checked . Is there a way to avoid this. If I am going to use a three button group configuration, I need to have them all unchecked initially. Thanks, Bill On May 7, 6:31 pm, E. Litwin elit...@rocketmail.com wrote: As the previous poster said, provide a Neither or None option and have that one be selected as the default when the page loads. That is much easier for a user to understand as well. On May 7, 2:28 pm, Hassan Schroeder hassan.schroe...@gmail.com wrote: On Thu, May 7, 2009 at 2:22 PM, zambezi b.but...@overhydration.org wrote: It appears that some ivory towered radio button designer never conceived that a user might click on a radio button group, change their mind and want to undo the click therefore returning to a false- false state. Quoting the HTML 4 spec: If no radio button in a set sharing the same control name is initially on, user agent behavior for choosing which control is initially on is undefined. Note. Since existing implementations handle this case differently, the current specification differs from RFC 1866 ([RFC1866] section 8.1.2.4), which states: At all times, exactly one of the radio buttons in a set is checked. If none of the INPUT elements of a set of radio buttons specifies `CHECKED', then the user agent must check the first radio button of the set initially. Since user agent behavior differs, authors should ensure that in each set of radio buttons that one is initially on. /quote If you want a no preference option, you should provide one explicitly. FWIW, -- Hassan Schroeder hassan.schroe...@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: url (view controller) error Need controller and action!
Hello Fred, With Ruby and Rails a whole new experience its sometimes difficult to even frame a coherent question. So thank you your answers and for going a step further and adding some very helpful explanation. It clarified my thinking Since I don't want to operate without protect_against_forgery and implementing a workaround isn't where I need to be spending time now, I searched about and came across some exmaples of a 'tableless' arrangement that implemented well with some minor modification. Thanks again. Bill On Apr 3, 5:43 pm, Frederick Cheung frederick.che...@gmail.com wrote: On Apr 3, 10:13 pm, zambezi b.but...@overhydration.org wrote: The punt didn't go far. This fix perhaps not unexpectedly resulted in the next error: ActionController::InvalidAuthenticityToken. Sooo, I'm at the deep end of the pool here. I really didn't want to learn all about authenticity tokens at this stage of my learning ruby. Any further suggestions will be much appreciated as to how to get past this error. Very short version: to protect against CSRF attacks, forms generated by rails have a hidden input with a magic token. Together with the session this helps verify that a request isn't been faked by a CSRF attack. With the protect_against_forgery returning false thing you've stopped your form trying to make such a token, but you still need to make the other end not expect a token. One way is to make your form use the GET method, another is to skip the verify_authenticity_token filter in the appropriate controller. Fred --~--~-~--~~~---~--~~ 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] url (view controller) error Need controller and action!
I thought I would set up a simple form for email noification to tinker with and see how it worked However the simplicity part has so far eluded me. Currently this particular page generates an error Need controller and action! when to my eyes everything is in order. Any suggestions as to what is going on. Thanks in advance. Bill ERROR ActionController::RoutingError in Emailer#send_mail Showing emailer/display.html.erb where line #71 raised: Need controller and action! Extracted source (around line #71): 71: % form_for(:emailer, :url = {:action = 'send_mail'}, :html = {:class = 'style1'}) do |f| % - FORM % form_for(:emailer, :url = {:action = 'send_mail'}, :html = {:class = 'style1'}) do |f| % %= label(:subject, 'Topic:') % %= f.select :subject, %w{ Hyponatremia/hydration Admin/ site }%br %= label(:comment, 'Comments:') % %= f.text_area :comment, :cols = 40, :rows = 10 % br %= label(:from, 'Name:') % %= f.text_field :from, :style = width: 200px; %br %= label(:senderemail, 'Email:') % %= f.text_field :senderemail, :style = width: 200px; %br %= submit_tag 'Send' % --- CONTROLLER class EmailerController ApplicationController def display render :action = 'display' end def send_mail Emailer.deliver_display (:subject, :comment, :senderemail, :from) end end --~--~-~--~~~---~--~~ 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: url (view controller) error Need controller and action!
Thank you, Fred. You were spot on. Explicitly designating the controller resolved the error. However that brought me to the next error/issue: NoMethodError in Emailer#send_mail Showing emailer/display.html.erb where line #71 raised: undefined method `protect_against_forgery?' for #ActionView::Base: 0x34d9c68 Extracted source (around line #71): 71: % form_for(:emailer, :url = {:controller = 'emailer', :action = 'send_mail'}, :html = {:class = 'style1'}) do |f| % RAILS_ROOT: C:/RubyRails/rails_apps/rappEAHv2 Application Trace | Framework Trace | Full Trace C:/RubyRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_view/helpers/form_tag_helper.rb:404:in `extra_tags_for_form' C:/RubyRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_view/helpers/form_tag_helper.rb:412:in `form_tag_html' C:/RubyRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_view/helpers/form_tag_helper.rb:41:in `form_tag' C:/RubyRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_view/helpers/form_helper.rb:183:in `form_for' app/views/emailer/display.html.erb:71:in `_run_erb_47app47views47emailer47display46html46erb' app/controllers/emailer_controller.rb:8:in `send_mail' -e:3:in `load' -e:3 -- Googling on the error didn't turn up much and generally seemed to attribute the problem to weirdness. One suggestion was that the problem's roots were due to plugin installation. But I haven't tinkered with the default installation plugins . Another suggestion was to create a new project and try again. I did and the issue persisted. There were a couple of suggestions to disable or dodge protect_against_forgery. I was unable to do so via the controller, but adding the following in the helper class punted the issue down the field. def protect_against_forgery? false end The punt didn't go far. This fix perhaps not unexpectedly resulted in the next error: ActionController::InvalidAuthenticityToken. Sooo, I'm at the deep end of the pool here. I really didn't want to learn all about authenticity tokens at this stage of my learning ruby. Any further suggestions will be much appreciated as to how to get past this error. Thanks, Bill On Apr 3, 3:02 am, Frederick Cheung frederick.che...@gmail.com wrote: On Apr 3, 3:19 am, zambezi b.but...@overhydration.org wrote: I thought I would set up a simple form for email noification to tinker with and see how it worked However the simplicity part has so far eluded me. Currently this particular page generates an error Need controller and action! when to my eyes everything is in order. The clue should be in the message - you're not supplying a controller :-) Normally if you don't supply the :controller option then the current one is implicit, but things are different when rendering an email. Fred --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---