3: Copyright Where you Where 2012
4: </small>
5:
6: <%= render @pages %>
Same again, @pages is nil. Try to look at the error and see if you
can understand what it means.
Colin
Well now what I have done his has follow
<%= render @page.name %>
And get the error has follow:
The partial name (About Us) is not a valid Ruby identifier; make sure
your partial name starts with a letter or underscore, and is followed by
any combinations of letters, numbers, or underscores.
So to me this should be the string About Us and placing has html. Did i
miss something??? I do know that the page.name = "About Us" But why not
just displaying it has a html string. What step did i confused.
Have a look at the Rails Guide on Layouts and Rendering. Section 2
describes how to use render, but read and understand the rest of it.
I forget whether you are a beginner. If so then work right through
some tutorials such as railstutorial.org to understand the basics of
Rails, also look at the other Rails Guides.
3: Copyright Where you Where 2012
4: </small>
5:
6: <%= render @pages %>
Same again, @pages is nil. Try to look at the error and see if you
can understand what it means.
Colin
Well now what I have done his has follow
<%= render @page.name %>
And get the error has follow:
The partial name (About Us) is not a valid Ruby identifier; make sure
your partial name starts with a letter or underscore, and is followed by
any combinations of letters, numbers, or underscores.
So to me this should be the string About Us and placing has html. Did i
miss something??? I do know that the page.name = "About Us" But why not
just displaying it has a html string. What step did i confused.
Have a look at the Rails Guide on Layouts and Rendering. Section 2
describes how to use render, but read and understand the rest of it.
I forget whether you are a beginner. If so then work right through
some tutorials such as railstutorial.org to understand the basics of
Rails, also look at the other Rails Guides.
Looking back I see that I have already advised that. How are you
getting on with the tutorials.
_footer.html would then have page links to my resources pages which
contains static links such About Us, Company News, etc... Based on this
tutorial
http://ruby.railstutorial.org/chapters/user-microposts#sec:manipulating_microposts
section 10.22 you must use render to allow to insert a file which you
then create which can be use if there is an association. However there
is no association, About Us and Company News aren't related to a user or
somesort.
Any solution that ruby can have if i dont have a model association
between those two field?
Yes I am new to Ruby on Rails. I have read and try several tutorial in
the last 2 weeks.
Reading several tutorials is not sufficient. Work right through
railstutorial.org, entering the code, running it, and doing the
exercises. Make sure you understand absolutely every line of code.
Reading several tutorials is not sufficient. Work right through
railstutorial.org, entering the code, running it, and doing the
exercises. Make sure you understand absolutely every line of code.
Colin
That my problem, I don't understand! I have try to make the tutorial but
i don't get it. Using example 10.22 it says to insert a micropost into a
user field you must do has follow
<%= render @resources %> into the location where you want the micropost
to appear or the content
You then create a file called _micropost.html.erb in the folder
micropost/_micropost.html.erb
And voila, to me this is how i see it, I do see that you might have to
define in the controller users @micropost.user to allow the association
to works. But in my program this particular model doesn't have an
association. Is there something I miss, does Rails allow a way to go
around this or no. Cause if no, then I must change language
Reading several tutorials is not sufficient. Work right through
railstutorial.org, entering the code, running it, and doing the
exercises. Make sure you understand absolutely every line of code.
Colin
That my problem, I don't understand! I have try to make the tutorial but
i don't get it. Using example 10.22 it says to insert a micropost into a
user field you must do has follow
<%= render @resources %> into the location where you want the micropost
to appear or the content
I can't find that in the tutorial. Which section and listing number is it in.
i don't get it. Using example 10.22 it says to insert a micropost into a
user field you must do has follow
<%= render @resources %> into the location where you want the micropost
to appear or the content
I can't find that in the tutorial. Which section and listing number is
it in.
Colin
its actually microposts i was refering resources to any resource or
model that exists has broader concept.
But it still his <%= render @microposts %> then you must create a file
with all the information that you want to show in the folder
microposts/_microposts.html.erb
Once this is done then you need to tell in the User controllers
def show
@user = User.find(params[:id])
@microposts = @user.microposts.paginate(page: params[:page])
end
But what if my model doesn't have a relation between the two! Then i
can't use it?
The reason I asked was that listing 10.30 shows how to render a fixed
page. Also the other advise I gave to study the rails guide on
rendering would do that. There really is no shortcut, you need to
learn stuff. The best way to start is by carrying on through the
tutorial and studying the rails guides.
Well the fartest i was was 9, but I retry today, i am going to scratch
it again, I did skip to best fit my program. But it remainds the main
issues is that I can't simply render a resource into an other page. Is
it at least possible?
The reason I asked was that listing 10.30 shows how to render a fixed
page. Also the other advise I gave to study the rails guide on
rendering would do that. There really is no shortcut, you need to
learn stuff. The best way to start is by carrying on through the
tutorial and studying the rails guides.
Colin
I understand well your telling me its possible which his good
I however re did everything from the tutorial and on the test i am
getting error
Here the command
bundle exec rspec spec/requests/static_pages_spec.rb
The result
F
Failures:
1) Static pages Home page should have the content 'Sample App'
Failure/Error: visit '/static_pages/home'
NoMethodError:
undefined method `visit' for
#<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0xa1695cc>
# ./spec/requests/static_pages_spec.rb:7:in `block (3 levels) in
<top (required)>'
Finished in 0.04033 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/requests/static_pages_spec.rb:6 # Static pages Home page
should have the content 'Sample App'
Why would visit not be defined? Thanks for your help, not sure why its
gives me this
Well the fartest i was was 9, but I retry today, i am going to scratch
it again, I did skip to best fit my program. But it remainds the main
issues is that I can't simply render a resource into an other page. Is
it at least possible?
The reason I asked was that listing 10.30 shows how to render a fixed
page. Also the other advise I gave to study the rails guide on
rendering would do that. There really is no shortcut, you need to
learn stuff. The best way to start is by carrying on through the
tutorial and studying the rails guides.
Colin
I understand well your telling me its possible which his good
I however re did everything from the tutorial and on the test i am
getting error
Here the command
bundle exec rspec spec/requests/static_pages_spec.rb
The result
F
Failures:
1) Static pages Home page should have the content 'Sample App'
Failure/Error: visit '/static_pages/home'
NoMethodError:
undefined method `visit' for
#<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0xa1695cc>
# ./spec/requests/static_pages_spec.rb:7:in `block (3 levels) in
<top (required)>'
Finished in 0.04033 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/requests/static_pages_spec.rb:6 # Static pages Home page
should have the content 'Sample App'
Why would visit not be defined? Thanks for your help, not sure why its
gives me this
My best guess would be that you have an error in the test code. If
you cannot see it then post static_pages_spec.rb here. Copy/paste it
from your actual code so we can check for typos.
rspec ./spec/requests/static_pages_spec.rb:6 # Static pages Home page
should have the content 'Sample App'
Why would visit not be defined? Thanks for your help, not sure why its
gives me this
My best guess would be that you have an error in the test code. If
you cannot see it then post static_pages_spec.rb here. Copy/paste it
from your actual code so we can check for typos.
Colin
Lol here what I have
spec/requests/static_pages_spec.rb
describe "Static pages" do
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
page.should have_content('Sample App')
end
end
end
rspec ./spec/requests/static_pages_spec.rb:6 # Static pages Home page
should have the content 'Sample App'
Why would visit not be defined? Thanks for your help, not sure why its
gives me this
My best guess would be that you have an error in the test code. If
you cannot see it then post static_pages_spec.rb here. Copy/paste it
from your actual code so we can check for typos.
Colin
Lol here what I have
spec/requests/static_pages_spec.rb
describe "Static pages" do
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
page.should have_content('Sample App')
end
end
end