" Be a Change Maker! Rural Information Tool "
Sunandan Madanl | Student - Programme in Rural Management | IRMA|
Roll No: 33084 |M: +919601409658 |
P
Please don't print this e-mail unless you really need to
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/249bedd5-91ba-4494-b6b7-a62df2909d4b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hi All,
I'm making a Rails app in which users have folders in which to organize
journal entries. I'm trying to load a partial into view that displays
D3.js visualizations based on the character count of each journal entry.
The JavaScript code and HTML inject properly, but I don't think the JS
is executing.
Show.js.erb looks like this:
$("#actual-right").append( "<%=j render :partial => 'contents', :locals
=> {:folder => @folder } %>" );
$("#jscripts").append("<%=j render :partial => 'show', formats: :js,
:locals => {:folder => @folder} %>");
The second line appends _show.js.erb with the rest of my JavaScript in
application.html.erb. The top line appends some HTML tags for D3.
I need to figure out how to execute the JavaScript so when a user clicks
the link to one of their folders, the HTML and JS are injected and the
graphs are drawn. Attached is my _show.js.erb file -- I have tried
wrapping all the D3 code in a function and calling it at the bottom, but
that didn't work.
Any advice would be appreciated!
Attachments:
http://www.ruby-forum.com/attachment/8638/_show.js.erb
--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1c7e5416b8beb12e5ae21b0781b4eaa1%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.
On Monday, July 29, 2013 2:15:38 PM UTC-4, Ruby-Forum.com User wrote:
I was working on this rails tutorial:
"http://guides.rubyon...ng_started.html" and than I got to the part that
you are supposed to show the title and data for an individual post (5.7)
and got an error when it was supposed to show the data, so I put
@post.inspect into /app/views/posts/show.html.erb and I got nil, and
same with the index page where it lists all of the posts, but I checked
and the data is in the database correctly.(in case this helps, on part
4.3 where you're supposed to uncomment # root to: "welcome#index", the
file said #root "welcome#index" instead, even though I'm using rails 4.0
and ruby 2.0) Here's my controller file:
class PostsController < ApplicationController
def new
end
def create
@post = Post.new(post_params.permit(:title, :text))
@post.save
redirect_to @post
end
private
def post_params
params.require(:post).permit(:title, :text)
end
def show
@post = Post.find(params[:id])
end
def index
@posts = Post.all
end
end
here's the error:
NoMethodError in Posts#show
Showing /home/hiram/rails/meme/app/views/posts/show.html.erb where line
#3 raised:
undefined method `title' for nil:NilClass
Extracted source (around line #3):
1 <p>
2 <strong>Title:</strong>
3 <%= @post.title %>
4 </p>
5
6 <p>
Rails.root: /home/hiram/rails/meme
--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b90f3d98-4074-4872-9fb1-5af6a74c61b6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.