Hi,all I''ve been trying to get this to work without any luck. in my _edit.rhtml view, I have the following thing <p> <%= form_remote_tag( :url=> {:action => ''check_place''} ,:before => "$(''place2'').value = $(''article_site'').value") %> <%= text_field_tag(''place2'') %> <%= submit_tag(''Check Place2'') %> <%= end_form_tag %> </p> in the controller,I have the function def check_place place = Place.find(:first, :conditions => [%{location = ? },params[:place2].downcase]) if place.nil? render :partial => ''get_more_info'' end end the _get_more_info.rhtml is something like this <head> <%= javascript_include_tag :defaults %> </head> <%= error_messages_for ''article'' %> <fieldset> <legend> Please enter some details </legend> </fieldset> so I expect this partial to be displayed when place.nil? is true. however, even if the program can get into this view, the view does not display at all. anybody having some ideas? I suspect the view is not written properly,something is missing. Thanks a lot! -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, thanks for the post. Anyway, could you explain exactly what you''re trying to do? -Conrad On 11/14/06, Jacquie Fan <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi,all > > I''ve been trying to get this to work without any luck. > > in my _edit.rhtml view, I have the following thing > <p> > <%= form_remote_tag( :url=> {:action => ''check_place''} ,:before => > "$(''place2'').value = $(''article_site'').value") %> > <%= text_field_tag(''place2'') %> > <%= submit_tag(''Check Place2'') %> > <%= end_form_tag %> > </p> > > in the controller,I have the function > def check_place > place = Place.find(:first, :conditions => [%{location = ? > },params[:place2].downcase]) > if place.nil? > render :partial => ''get_more_info'' > end > end > > the _get_more_info.rhtml is something like this > > <head> > <%= javascript_include_tag :defaults %> > </head> > > <%= error_messages_for ''article'' %> > <fieldset> > <legend> Please enter some details </legend> > > </fieldset> > > so I expect this partial to be displayed when place.nil? is true. > however, even if the program can get into this view, the view does not > display at all. > > anybody having some ideas? I suspect the view is not written > properly,something is missing. > > Thanks a lot! > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
sure,so I need to know whether the place I entered exists in my database or not. if it is in the database then I print out Query OK. If it does not exist,I want to invoke a form asking for more information. so in _edit.rhtml,I press Check Place button to trigger the check_place function in the controller. and in the controller I try to figure out if that place exists. and if it doesnt(place.nil?=true),I need to render_partial "get_more_info". So it all worked fine until it gets to the get_more_info partial. whatever I write in that partial file _get_more_info.rhtml, it doesnt get displayed at all. however, as I can see, the controller is able to find _get_more_info.rhtml. I suspect something might be wrong in _get_more_info.rhtml but not sure where exactly the problem is. Any hints? Thanks for you 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jacquie Fan wrote:> Hi,all > > I''ve been trying to get this to work without any luck. > > in my _edit.rhtml view, I have the following thing > <p> > <%= form_remote_tag( :url=> {:action => ''check_place''} ,:before => > "$(''place2'').value = $(''article_site'').value") %> > <%= text_field_tag(''place2'') %> > <%= submit_tag(''Check Place2'') %> > <%= end_form_tag %> > </p> > SNIP... > so I expect this partial to be displayed when place.nil? is true. > however, even if the program can get into this view, the view does not > display at all. > > anybody having some ideas? I suspect the view is not written > properly,something is missing. > > Thanks a lot!Hi Jacquie, Do you know about "development.log"? This is a log file that often has some useful info in it when things are going poorly. You will find it in the "logs" folder in your Rails project root. Just taking a stab at this from what you''ve said, I''m a little unsure about how you''re trying to do the render :partial from the controller. There''s more than one way to skin a Republican, but what I would be doing in this instance is to have something like: <div id=''error_stuff STYLE=''display: none;'' > <%= render :partial => ''get_more_info'' %> </div> at an appropriate spot in my "edit" view. Then in my conditional stuff in the controller I would use something like: render :update do |page| page.visual_effect :BlindDown, "error_stuff", :duration => 1.0, :queue => "end" end to make the error stuff slide into view with ajax. Another thing to consider that would be simpler would be to use the "Flash" helper in Rails as described on page 88 of the Agile Rails book: <% if @flash[:notice] -%> <div id="notice"><%= @flash[:notice] %></div> <% end -%> Then your controller just has to: flash[:notice] = ''Please Enter Some Details'' hth, jp -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, I have a table storing greeting messages that I need to be converted to html. Is there a rails way of doing this? Thanks in advance, 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the reply,Jeff. Yes,I know development.log, thanks for reminding me. the thing is whether to render this partial get_more_info is controlled by the controller. so how would I do that in the edit.rhtml view? Jeff Pritchard wrote:>-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
1) use <%= debug(''place'') %> to check your variable in the view 2) I would move the conditional statements to the view like this:> <% unless place %> > <%= render :partial => ''get_more_info'' %>-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You''re doing <%= error_messages_for ''article'' %> in your partial, but in check_place you''re not defining @article (unless there is some other code you haven''t shown). A more general tip. Download Firebug now. I mean it. It''s a firefox extension that I consider absolutely vital when working with ajax, you can see all the ajax requests you have made (and their response), it flags javascript errors, has a dom inspector etc... Fred -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Can you clarify the problem you''re having? Jason On 11/14/06, Chris H <chris-W4T7yFXR9VraRrIkyKz72Q@public.gmane.org> wrote:> > > Hi, > > I have a table storing greeting messages that I need to be converted to > html. > > Is there a rails way of doing this? > > Thanks in advance, > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jacquie Fan wrote:> Thanks for the reply,Jeff. > > Yes,I know development.log, thanks for reminding me. the thing is > whether to render this partial get_more_info is controlled by the > controller. so how would I do that in the edit.rhtml view? > > Jeff Pritchard wrote: >>Oh! I think I understand how you are going at this thing. Have a look at "replace_html" instead of "render :partial". The problem is you are trying to render a partial from your controller, and AFAIK that can''t be done. There is nothing to tell it where in the page to render it. From your original post, it looks like you''re doing this in ajax land, so in your controller you can do a render :update with replace_html. You need to put an empty "div" in your edit view where you want it to show up and give the div an "id". Then replace that div with your partial using "replace_html" and render :update. Make sense? hth, jp -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---