I know I''m missing something. Invariably, whenever I try to add some
kind of RJS action to a page it never "just works".
I''m working on a page that will be the user''s primary
interface with
the site. If I can, I''ll make it the only interface. I''d like
all the
other forms to come up as "dialogs" on top of the normal page.
I''m
working on the first of those now. I''ve got a link_to_remote tag,
going off to a resource''s controller and the "new" action.
I''ve got
the new.rjs.erb file in the correct views sub-directory. But when I
click on the generated tag, I get a MissingTemplate exception because
there is no new.html.erb file. I can''t see anything in the url_for,
link_to, or link_to_remote options that will let me explicitly set the
content type of the request. Basically, I want the response to always
be an rjs template. How do I make this work?
Thanks for your help!
Mark
------------------------------------
The page with the link:
...
<tr>
<td>
<%= link_to_remote "Add Joke", :url => { :controller =>
''jokes'', :action => ''new'' } %>
</td>
<td>
</td>
</tr>
...
The controller:
class JokesController < ApplicationController
def new
@joke = Joke.new
end
end
The new.rjs.erb file:
page.insert_html :bottom, ''content'', :partial =>
"newJoke", :object =>
@joke
The _newJoke.html.erb file:
<div class="newJokeDialog">
<% remote_form_for :newJoke do |form| -%>
<%= form.text_area :content, :rows => 10, :cols => 80 %>
<% end -%>
</div>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
The naming standard is now <action>.<format>.<renderer> so try
naming
your file ''new.js.rjs''. This will help rails figure out how
to return
''js'' using the ''rjs'' rendering.
You may also need to add the respond_to block so that the framework
understands that you want to deal with more than just the default html
rendering:
...
def new
@joke = Joke.new
respond_to do |wants|
wants.html # new.html.erb
wants.js # new.js.rjs
end
end
...
HTH,
AndyV
On Apr 13, 1:28 pm, Mark Slater
<markd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I know I''m missing something. Invariably, whenever I try to add
some
> kind of RJS action to a page it never "just works".
>
> I''m working on a page that will be the user''s primary
interface with
> the site. If I can, I''ll make it the only interface. I''d
like all the
> other forms to come up as "dialogs" on top of the normal page.
I''m
> working on the first of those now. I''ve got a link_to_remote tag,
> going off to a resource''s controller and the "new"
action. I''ve got
> the new.rjs.erb file in the correct views sub-directory. But when I
> click on the generated tag, I get a MissingTemplate exception because
> there is no new.html.erb file. I can''t see anything in the
url_for,
> link_to, or link_to_remote options that will let me explicitly set the
> content type of the request. Basically, I want the response to always
> be an rjs template. How do I make this work?
>
> Thanks for your help!
>
> Mark
>
> ------------------------------------
>
> The page with the link:
> ...
> <tr>
> <td>
> <%= link_to_remote "Add Joke", :url
=> { :controller =>
> ''jokes'', :action => ''new'' } %>
> </td>
> <td>
>
> </td>
> </tr>
> ...
>
> The controller:
>
> class JokesController < ApplicationController
>
> def new
> @joke = Joke.new
> end
>
> end
>
> The new.rjs.erb file:
>
> page.insert_html :bottom, ''content'', :partial =>
"newJoke", :object =>
> @joke
>
> The _newJoke.html.erb file:
>
> <div class="newJokeDialog">
> <% remote_form_for :newJoke do |form| -%>
> <%= form.text_area :content, :rows => 10, :cols =>
80 %>
> <% end -%>
> </div>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Awesome, thank you that worked! Mark On Apr 14, 2008, at 8:50 AM, AndyV wrote:> > The naming standard is now <action>.<format>.<renderer> so try naming > your file ''new.js.rjs''. This will help rails figure out how to return > ''js'' using the ''rjs'' rendering. > > You may also need to add the respond_to block so that the framework > understands that you want to deal with more than just the default html > rendering: > > ... > def new > @joke = Joke.new > respond_to do |wants| > wants.html # new.html.erb > wants.js # new.js.rjs > end > end > ... > > HTH, > AndyV > > On Apr 13, 1:28 pm, Mark Slater <markd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> I know I''m missing something. Invariably, whenever I try to add some >> kind of RJS action to a page it never "just works". >> >> I''m working on a page that will be the user''s primary interface with >> the site. If I can, I''ll make it the only interface. I''d like all the >> other forms to come up as "dialogs" on top of the normal page. I''m >> working on the first of those now. I''ve got a link_to_remote tag, >> going off to a resource''s controller and the "new" action. I''ve got >> the new.rjs.erb file in the correct views sub-directory. But when I >> click on the generated tag, I get a MissingTemplate exception because >> there is no new.html.erb file. I can''t see anything in the url_for, >> link_to, or link_to_remote options that will let me explicitly set >> the >> content type of the request. Basically, I want the response to always >> be an rjs template. How do I make this work? >> >> Thanks for your help! >> >> Mark >> >> ------------------------------------ >> >> The page with the link: >> ... >> <tr> >> <td> >> <%= link_to_remote "Add Joke", :url => >> { :controller => >> ''jokes'', :action => ''new'' } %> >> </td> >> <td> >> >> </td> >> </tr> >> ... >> >> The controller: >> >> class JokesController < ApplicationController >> >> def new >> @joke = Joke.new >> end >> >> end >> >> The new.rjs.erb file: >> >> page.insert_html :bottom, ''content'', :partial => "newJoke", :object >> => >> @joke >> >> The _newJoke.html.erb file: >> >> <div class="newJokeDialog"> >> <% remote_form_for :newJoke do |form| -%> >> <%= form.text_area :content, :rows => 10, :cols => >> 80 %> >> <% end -%> >> </div> > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---