Joshua Mckinney wrote:
[...]
Personally I don't like working with rjs , unless I have to, and I
usually convert that code over to a js.erb file if I can.
Just a short note. I think I share your dislike of RJS (though I have
recently noticed a few things that may make me rethink that opinion),
If the request is getting the correct method which creates comment,
then the request is probably working correctly.
I usually try to use the create methods for a model in the
corresponding controller, so if I create a new comment (even if its
originates from the stories view), I simply format my
Just to be clear, this is an ajax request correct?
I believe your create method is inside your comments controller, if
this is true then by default rails will look for views associated to
the methods in the comments controller in comments view folder (/
views/comments/some views).
You
Joshua Mckinney wrote:
Just to be clear, this is an ajax request correct? TRUE
I believe your create method is inside your comments controller, TRUE
You could try to use the render method to specify the location of the
view like (i have not tried this with an ajax request):
render
Have you tried naming the file create.js.rjs?
On Aug 2, 11:46 am, Neil Bye li...@ruby-forum.com wrote:
Joshua Mckinney wrote:
From inside your create method in the controller, what does
request.format return?
If the request is a plain old html request is should put text/html
If the
Joshua Mckinney wrote:
Have you tried naming the file create.js.rjs?
Good idea but no difference.
The latest configuration of the create function is:
def create
@story = Story.find(params[:story_id])
@story.comments.create params[:comment]
request.format = :js
end
Gives a page
Latest development. I've changed the ajax call stories/show.html.erb to
div id='aremark'
%= render :partial = 'comment' %
/div
h5label for=loginMake a comment:/label/h5
% remote_form_for :comment, :update ='aremark',
:url=story_comments_path(@story) do |form| %
div id=body%=
The 2 most direct causes I can think of that would produce that error
would be:
1. create.js.rjs is not in the correct director (.../app/views/
comments/create.js.rjs
2. create.js.rjs does not exist or bad file name
Try using:
def create
@story = Story.find(params[:story_id])
Joshua Mckinney wrote:
Try using:
def create
@story = Story.find(params[:story_id])
@story.comments.create params[:comment]
request.format = :js
respond_to do |format|
format.js
end
end
Although respond _to blocks are not always necessary, it can't hurt to
On Aug 2, 12:53 am, Neil Bye li...@ruby-forum.com wrote:
I didn't really want the whole page refresh I was only using it coz the
rjs wasn't working. I want the .rjs coz I want comments to go straight
up with no refresh.
Are you saying I should make a line
page.redirect_to
If you want a redirect from rjs that is how you do it
(the :controller bit isn't needed). That will do a full page refresh
do.
Fred
The trouble is that it's not even getting to the .rjs. That has been my
problem all along.
When I click the 'cmment button I get
Comment Create
On Aug 2, 10:51 am, Neil Bye li...@ruby-forum.com wrote:
If you want a redirect from rjs that is how you do it
(the :controller bit isn't needed). That will do a full page refresh
do.
Fred
The trouble is that it's not even getting to the .rjs. That has been my
problem all along.
�The trouble is that it's not even getting to the .rjs. That has been my
problem all along.
When I click the 'cmment button I get
If all you've got is a .rjs file you don't need the respond_to block
at alll
Fred
I do need the .rjs to do the page.html_replace I,ve benn tring to do
On Aug 2, 11:25 am, Neil Bye li...@ruby-forum.com wrote:
I do need the .rjs to do the page.html_replace I,ve benn tring to do
all along.
I just can't get to create.rjs Here it is
page.replace_html 'aremark', partial = 'comment'
page.redirect_to story_path(@story), :controller =
Your log files say this is happening in your comments controller so it
should be in app/views/comments.
Fred
There is a copy in app/views/comments. I've attached show.html.erb in
case there is something I missed. The link_to, which is there as a test,
works.
This is how the comment
On Aug 2, 12:52 pm, Neil Bye li...@ruby-forum.com wrote:
Your log files say this is happening in your comments controller so it
should be in app/views/comments.
Fred
There is a copy in app/views/comments. I've attached show.html.erb in
case there is something I missed. The link_to,
Is there anything else I could send that might solve this?
The respond_to is unnecessary if you're only ever going to be using
the rjs template for this action
Fred
I'm sorry this is being so difficult.
The create function now looks like this:
def create
@story =
Check your rjs code. Run debugger and insert %debugger% at the very
top of the rjs file, if catches the debugger then you have an rjs code
error. Install firebug and view the returned javascript. Since the rjs
is rendered after the insert your insert would reflect in the log but
bad rjs code would
On Aug 2, 2:01 pm, Neil Bye li...@ruby-forum.com wrote:
def create
@story = Story.find(params[:story_id])
@story.comments.create params[:comment]
format.js
end
The log now says
ArgumentError (too few arguments):
app/controllers/comments_controller.rb:12:in `format'
Joshua Mckinney wrote:
Check your rjs code. Run debugger and insert %debugger% at the very
top of the rjs file, if catches the debugger then you have an rjs code
error. Install firebug and view the returned javascript. Since the rjs
is rendered after the insert your insert would reflect in the
Frederick Cheung wrote:
On Aug 2, 2:01�pm, Neil Bye li...@ruby-forum.com wrote:
� app/controllers/comments_controller.rb:12:in `format'
� end
i was saying you need neither -
� def create
� � @story = Story.find(params[:story_id])
� � @story.comments.create params[:comment]
end
Check your rjs code. Run debugger and insert %debugger% at the very
top of the rjs file, if catches the debugger then you have an rjs code
error. Install firebug and view the returned javascript. Since the rjs
is rendered after the insert your insert would reflect in the log but
bad rjs code would
From inside your create method in the controller, what does
request.format return?
If the request is a plain old html request is should put text/html
If the request is an ajax request is should put text/javascript
if the request puts text/html or anything besides text/javascript
you can force
On Aug 2, 3:36 pm, Neil Bye li...@ruby-forum.com wrote:
i was saying you need neither -
def create
@story = Story.find(params[:story_id])
@story.comments.create params[:comment]
end
How then would it create the comment?
why wouldn't it ? - that's creating the comment on
Joshua Mckinney wrote:
From inside your create method in the controller, what does
request.format return?
If the request is a plain old html request is should put text/html
If the request is an ajax request is should put text/javascript
if the request puts text/html or anything besides
| 302 Found [http://localhost/stories/5/comments]
What does this bit at the bottom refer to?
--
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
On Aug 1, 3:37 pm, Neil Bye li...@ruby-forum.com wrote:
| 302 Found [http://localhost/stories/5/comments]
What does this bit at the bottom refer to?
That's saying that the response was a 302 and that the url that rails
has just finished processing is http://localhost/stories/5/comments
Is
Is there anything unusual in the view that triggers this?
Fred
This is the view:
div id=sidebar
%= render :partial = 'sidebar' %
/div
h1%= @story.user.login %'s story /h1
br
%= render :partial = 'friend' %
h4Content/h4
div id=story%= @story.body %/div
div id='aremark'
%= render
Neil Bye wrote:
Is there anything unusual in the view that triggers this?
Fred
This is the problem line from the view:
% remote_form_for :comment, :url=story_comments_path(@story), :html
= { :id = 'comment' } do |form| %
div id=body%= form.text_field :body %/div
On 1 Aug, 23:42, Neil Bye li...@ruby-forum.com wrote:
Neil Bye wrote:
Is there anything unusual in the view that triggers this?
Fred
This is the problem line from the view:
% remote_form_for :comment, :url=story_comments_path(@story), :html
= { :id = 'comment' } do |form| %
That's why your redirect doesn't work - the redirect just redirects
the request made by the JavaScript (rjs has a page.redirect_to thing
that will produce the JavaScript required to point the browser window
at a new location. If you are going to do a full page refresh though,
what's the
31 matches
Mail list logo