Hi guys, the next problem: I create a controller, (/controllers/rmagick_controller.rb), which have aim to test an captcha Actions: def download # creates an captcha image def show # show the page where image took place def check # must check right captcha or wrong views/rmagick/show.html.erb:> <div id="captcha"> > <p><%= image_tag download_rmagick_path %></p> > > <p><% form_tag check_rmagick_path do %> > <p><%= text_field_tag :captcha %></p> > <p><%= submit_tag "Submit" %></p> > <% end %> > </p> > </div>config/routes.rb:> resources :rmagick do > get "download", :on => :member > get "check", :on => :member > endSo, there are 2 problems: 1) Routes problem. If I''m write in config/routes.rb something like this:> get "rmagick/show" > get "rmagick/download" > get "rmagick/check"I catch this output:> No route matches {:action=>"download", :controller=>"rmagick"}But I''m place get "rmagick/download" in routes.rb. Why it doesn''t work? (it can''t find download_rmagick_path) So, if I use resources :rmagick do ... I see an show.html.erb when i write something other than "show" text, ie in this link 127.0.0.1:3000/rmagick/jjvniuv I also will see show action.why? How I can change this? Where is the problem? 2) Problem with form_tag. So, you see the code above. When I put captcha value and press "submit" button, I don''t go to rmagick/check, I go to rmagick/show/check. Why? 3) When I''ll create all of this, how I can do interaction between other pages and captcha? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sep 9, 10:54 am, Misha Ognev <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi guys, the next problem: > > I create a controller, (/controllers/rmagick_controller.rb), which have > aim to test an captcha > > Actions: > def download # creates an captcha image > def show # show the page where image took place > def check # must check right captcha or wrong > > views/rmagick/show.html.erb: > > > <div id="captcha"> > > <p><%= image_tag download_rmagick_path %></p> > > > <p><% form_tag check_rmagick_path do %> > > <p><%= text_field_tag :captcha %></p> > > <p><%= submit_tag "Submit" %></p> > > <% end %> > > </p> > > </div> > > config/routes.rb: > > > resources :rmagick do > > get "download", :on => :member > > get "check", :on => :member > > endRails understand this as creating urls like rmagick/123/download, i.e. it things there are actual rmagick entities which supports a download action This means that when you call download_rmagick_path rails is expecting you to supply it with the id of the rmagick entity. If you don''t rails won''t be able to generate a url. You''d probably need to either switch to a singleton resource, make those actions collection actions, use match rather than creating a resource. The rails routing guide should explain the difference between these actions> > So, there are 2 problems: > > 1) Routes problem. If I''m write in config/routes.rb something like this: > > > get "rmagick/show" > > get "rmagick/download" > > get "rmagick/check" > > I catch this output:> No route matches {:action=>"download", :controller=>"rmagick"} > > But I''m place get "rmagick/download" in routes.rb. Why it doesn''t work? > (it can''t find download_rmagick_path) > > So, if I use resources :rmagick do ... I see an show.html.erb when i > write something other than "show" text, ie in this link > 127.0.0.1:3000/rmagick/jjvniuv I also will see show action.why? How I > can change this? Where is the problem?That''s what it''s supposed to do - given the routes you''ve defined, / rmagick/jjvniuv is the path for the rmagick entity with the id jjvniuv> > 2) Problem with form_tag. So, you see the code above. When I put captcha > value and press "submit" button, I don''t go to rmagick/check, I go to > rmagick/show/check. Why? >I''m surprised it does anything at all. You''ve got the same problem as earlier - a route that is expecting an id, but you''re not giving it an id. You might also want to look at the recaptcha captcha - it''s very easy to integrate Fred> 3) When I''ll create all of this, how I can do interaction between other > pages and captcha? > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks, Fred.> You might also want to look at the recaptcha captcha - it''s very easy > to integrateBut I want my own captcha. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Fred, now I''m> You''d probably need to either switch > to a singleton resource, make those actions collection actions, use > match rather than creating a resource.Can you explain example, what I must to do? Guide "Rails routing from outside in" not gived clarity to me. 3) So, when I create a methods that can create captcha image and check it, what i must do next? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sep 10, 12:35 pm, Misha Ognev <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Fred, now I''m> You''d probably need to either switch > > to a singleton resource, make those actions collection actions, use > > match rather than creating a resource. > > Can you explain example, what I must to do? Guide "Rails routing from > outside in" not gived clarity to me. > > 3) So, when I create a methods that can create captcha image and check > it, what i must do next? >I think you need to think about this bit first - the right routes will depend on how this is going to be used. For example, I don''t think you need a check action for the captcha - the user''s answer to the captcha would be submitted along with the other information they''re supplying and verification done in the controller. The only captcha specific action I think you need is the one that actually produces the image. The form probably also needs to contain enough information to allow you to know which captcha the user is solving. You''ll probably also want to ensure that the same captcha/answer can''t be used by someone over and over again. Even if you want to write your own, you might find existing captcha systems a useful source of inspiration. Fred Fred> -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Fred, I understand a simple_captcha conception. Now I faced with this problem: I create an captcha_controller.rb, when in def generate... end I put a code to create captcha image. Then I write in config/routes.rb:> match ''captcha'' => ''captcha/generate''And in _generator.html.erb:> <%= image_tag(captcha_path) %>So, I have this error, when I open 127.0.0.1:3000/captcha:> ActionController::RoutingError (uninitialized constant Captcha):Why this error occured? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sep 12, 1:16 pm, Misha Ognev <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Fred, I understand a simple_captcha conception. Now I faced with this > problem: > > I create an captcha_controller.rb, when in def generate... end I put a > code to create captcha image. > > Then I write in config/routes.rb: > > > match ''captcha'' => ''captcha/generate'' >You probably want ''captcha#generate'' rather than ''captcha/generate'' - with what you''ve got I think rails will look for Captcha::GenerateController instead of routing to the generate action of CaptchaController Fred> And in _generator.html.erb: > > > <%= image_tag(captcha_path) %> > > So, I have this error, when I open 127.0.0.1:3000/captcha: > > > ActionController::RoutingError (uninitialized constant Captcha): > > Why this error occured? > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks, this really works. Can you tell me lesson of rails routing other than guides.rubyonrails.org? (I cannot understand some things here) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
So, I have another one problem. How can I do a method in controller, that the same ".valid_with_captcha?" When I puts to application_controller.rb> def valid_with_captcha? > if self.valid? and captcha_valid? then true else false end > endAnd, supposably, in users_controller.rb> def update > if @user.valid_with_captcha? > save_code > end > endWhen I''m updating, I see this:> undefined method `valid_with_captcha?'' for #<User:0x00000003f8e6b8>What''s 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
bump! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.