Unable to follow basic RoR tutorial (Win32)

I have just set up RoR to find out for myself if this tool is stable
enough to actually be used yet.

Anyhow, I started by going to the RubyOnRails website and following the
instructions to install the platform on my Windows 2000 PC.

“Get Ruby on Rails in no time”
“We recommend Ruby 1.8.4 for use with Rails.”
So… I downloaded 1.8.4 and installed:

C:>ruby -v
ruby 1.8.4 (2006-04-14) [i386-mswin32]

Great…

Then I’m told to “gem install rails --include-dependencies”

So, I did that…

C:>rails -v
Rails 1.1.4

Then started following the tutorial here:
http://media.rubyonrails.org/video/rails_take2_with_sound.mov

Great, this all looks really cool, let me try and do it… All goes well
until 7:20 into the demo. I do exactly the same and get this error in my
brouser:


ArgumentError in Blog#list

Showing app/views/blog/list.rhtml where line #8 raised:

wrong number of arguments (1 for 0)

Extracted source (around line #8):

5:

<%= link_to post.title, :action => ‘show’, :id => post %>


6:

<%= post.body %>


7:


8: <%= post.created_at.to_s(“:long”) %>
9: (<%= link_to ‘Edit’, :action => ‘edit’, :id => post %>)
10:


11:

RAILS_ROOT: ./script/…/config/…
Application Trace | Framework Trace | Full Trace

#{RAILS_ROOT}/app/views/blog/list.rhtml:8:in to_s' #{RAILS_ROOT}/app/views/blog/list.rhtml:8:in _run_rhtml_blog_list’
#{RAILS_ROOT}/app/views/blog/list.rhtml:3:in `_run_rhtml_blog_list’

c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:314:in
compile_and_render_template' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:290:in render_template’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:249:in
render_file' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:699:in render_file’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:621:in
render_with_no_layout' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/layout.rb:243:in render_without_benchmark’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:53:in
render' c:/ruby/lib/ruby/1.8/benchmark.rb:293:in measure’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:53:in
render' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:911:in perform_action_without_filters’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:368:in
perform_action_without_benchmark' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:69:in perform_action_without_rescue’
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in measure' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:69:in perform_action_without_rescue’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/rescue.rb:82:in
perform_action' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:381:in process_without_filters’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:377:in
process_without_session_management_support' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/session_management.rb:117:in process’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in
dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:115:in handle_dispatch’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:81:in
service' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in service’
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in run' c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in start_thread’
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in start’
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in start' c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in start’
c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in start' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:67:in dispatch’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/servers/webrick.rb:59
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
require' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in require’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/server.rb:30
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
require' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in require’
script/server:3

#{RAILS_ROOT}/app/views/blog/list.rhtml:8:in to_s' #{RAILS_ROOT}/app/views/blog/list.rhtml:8:in _run_rhtml_blog_list’
#{RAILS_ROOT}/app/views/blog/list.rhtml:3:in _run_rhtml_blog_list' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:314:in compile_and_render_template’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:290:in
render_template' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:249:in render_file’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:699:in
render_file' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:621:in render_with_no_layout’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/layout.rb:243:in
render_without_benchmark' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:53:in render’
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in measure' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:53:in render’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:911:in
perform_action_without_filters' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:368:in perform_action_without_benchmark’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' c:/ruby/lib/ruby/1.8/benchmark.rb:293:in measure’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/rescue.rb:82:in perform_action’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:381:in
process_without_filters' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:377:in process_without_session_management_support’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/session_management.rb:117:in
process' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in dispatch’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:115:in
handle_dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:81:in service’
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in service' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in run’
c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in start_thread’
c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in start' c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in start’
c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in start' c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in start’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:67:in
dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/servers/webrick.rb:59 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in require’
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
require' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/server.rb:30 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in require’
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require’
script/server:3

Request

Parameters: None

Show session dump


flash: !map:ActionController::Flash::FlashHash {}

Response
Headers: {“cookie”=>[], “Cache-Control”=>“no-cache”}


It seems that the (:long) on the to_s does not work. I tryed to find
things about this already and it seems that there were similar problems
10 months ago (http://dev.rubyonrails.org/ticket/2344) and at the start
of the year here (SQL Server datetime error - Rails - Ruby-Forum) and it seems
that the problem still exists.

Basically, what I want to know is, is this platform really worth me
spending any more time looking into or does it need a few more years
before it will really be stable enough to be useful. (Mind you, bugs
that have been known about for 10 months and still not fixed, perhaps a
few more years would not be enough).

What are your oppinions about this?

Mark,

I haven’t done the tutorial that you are talking about but it appears
there is a bug in your code, you aren’t supposed to put symbols in
quotes. So line #8 (exactly where the error message pointed) should be
like this:

<%= post.created_at.to_s(:long) %>

More than likely that will fix your bug which was simply a Ruby syntax
error.

Given the vibrant community of intelligent people I think Rails is
ready to go. Now. There will always be bugs in documentation,
tutorials and code. Especially when a framework is changing as quickly
as Rails does. It takes just a little more effort on the developer’s
part to keep up with the changes.

Welcome to Rails! I hope you enjoy your stay.

Carl

You’re watching a video that’s pretty old and was really never meant to
be a
tutoral. It’s more of an marketing ploy. This framework changes very
fast
but the pain is worth it. Everyone here who uses this professionally
finds
it very much worth it. Not only because we’re more productive, but
because
it’s fun.

Also, this looks wrong:

<%= post.created_at.to_s(":long") %>

But this looks right…

<%= post.created_at.to_s(:long) %>

:long is a symbol, something special and unique to Ruby. It’s not
meant to
be embedding in a string.

From my own app as proof:

event = Event.find :first
event.created_at.to_s(:long)
“August 04, 2006 10:52”

Good luck with your journey on the Rails.

-Brian

Wow… Guys are really freindly and supper quick… Thank you! :slight_smile:

Actually that was not the bug though :(. I hit the problem initially and
tryed putting "'s in to see what would happen with “%e”, “%Y”, “:long”
etc. Then forgot to take them out for my example post, to prove I still
have the problem here is a new extract after having removed the quotes:


ArgumentError in Blog#list

Showing app/views/blog/list.rhtml where line #8 raised:

wrong number of arguments (1 for 0)

Extracted source (around line #8):

5:

<%= link_to post.title, :action => ‘show’, :id => post %>


6:

<%= post.body %>


7:


8: <%= post.created_at.to_s(:long) %>
9: (<%= link_to ‘Edit’, :action => ‘edit’, :id => post %>)
10:


11:

RAILS_ROOT: ./script/…/config/…
Application Trace | Framework Trace | Full Trace

#{RAILS_ROOT}/app/views/blog/list.rhtml:8:in to_s' #{RAILS_ROOT}/app/views/blog/list.rhtml:8:in_run_rhtml_blog_list’
#{RAILS_ROOT}/app/views/blog/list.rhtml:3:in `_run_rhtml_blog_list’

c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:314:in
compile_and_render_template' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:290:inrender_template’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:249:in
render_file' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:699:inrender_file’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:621:in
render_with_no_layout' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/layout.rb:243:inrender_without_benchmark’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:53:in
render' c:/ruby/lib/ruby/1.8/benchmark.rb:293:inmeasure’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:53:in
render' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:911:inperform_action_without_filters’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:368:in
perform_action_without_benchmark' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:69:inperform_action_without_rescue’
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in measure' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:69:inperform_action_without_rescue’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/rescue.rb:82:in
perform_action' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:381:inprocess_without_filters’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:377:in
process_without_session_management_support' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/session_management.rb:117:inprocess’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in
dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:115:inhandle_dispatch’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:81:in
service' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:inservice’
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in run' c:/ruby/lib/ruby/1.8/webrick/server.rb:173:instart_thread’
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:95:instart’
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in start' c:/ruby/lib/ruby/1.8/webrick/server.rb:23:instart’
c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in start' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:67:indispatch’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/servers/webrick.rb:59
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
require' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:inrequire’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/server.rb:30
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
require' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:inrequire’
script/server:3

#{RAILS_ROOT}/app/views/blog/list.rhtml:8:in to_s' #{RAILS_ROOT}/app/views/blog/list.rhtml:8:in_run_rhtml_blog_list’
#{RAILS_ROOT}/app/views/blog/list.rhtml:3:in _run_rhtml_blog_list' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:314:incompile_and_render_template’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:290:in
render_template' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:249:inrender_file’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:699:in
render_file' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:621:inrender_with_no_layout’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/layout.rb:243:in
render_without_benchmark' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:53:inrender’
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in measure' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:53:inrender’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:911:in
perform_action_without_filters' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:368:inperform_action_without_benchmark’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' c:/ruby/lib/ruby/1.8/benchmark.rb:293:inmeasure’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/rescue.rb:82:inperform_action’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:381:in
process_without_filters' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:377:inprocess_without_session_management_support’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/session_management.rb:117:in
process' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:indispatch’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:115:in
handle_dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:81:inservice’
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in service' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:162:instart_thread’
c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in start' c:/ruby/lib/ruby/1.8/webrick/server.rb:92:instart’
c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in start' c:/ruby/lib/ruby/1.8/webrick/server.rb:82:instart’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:67:in
dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/servers/webrick.rb:59 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
require' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/server.rb:30 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require’
script/server:3

Request

Parameters: None

Show session dump


flash: !map:ActionController::Flash::FlashHash {}

Response
Headers: {“cookie”=>[], “Cache-Control”=>“no-cache”}


Thank you for your reply though, sorry that it didn’t solve the problem.

Mark.

With respect to the framework changing…

I started our rails app last year when Rails was “pre-release”. I have
since upgraded a few times to various releases and much to my amazement,
all of my code has continued to work with one exception. The ONLY
problem I have had was when I upgraded engines (to use date_box engine)
and my LoginEngine broke. I simply upgraded my LoginEngine to the
latest version and then everything started working properly again.

Is my experience unique? I don’t feel like I have had any pain with the
framework evolving and expanding. Maybe my app is so basic that it
doesn’t break - but I feel that I do a lot within it.

A few days ago there was a thread on this forum about RadRails which has
a lot of helpful information in it for new people to Rails/RadRails. I
suggest searching or looking through the archives for this weeks posts
to find that article.

Regards,

Michael

Alex W. wrote:

Mark wrote:

wrong number of arguments (1 for 0)

8: <%= post.created_at.to_s(:long) %>

Only the Time and Date classes have a parameter that can be passed to
the to_s method. I think your database is not returning a Time object.
Try this to troubleshoot.

change line #8 to:
<%= post.created_at.class %>

This should render out “Time” if it doesn’t, you have the wrong datatype
set on that database column. Change the database column data type to
“datetime” (on mysql, not sure of others) and it should work fine.

The basic logic here is that if the to_s method does not take a
parameter, that the object it’s called on is not a date.

Though polymorphism is powerful, it can be tricky at times.

Also, as for the stability of the framework, issues like these are very
very rarely the fault of the framework. These types of exceptions, no
matter how cryptic the actual error may seem, are almost always the
fault of the programmer. And on the few times that the framework does
indeed have a bug, its pretty simply to write a patch/plugin to fix it.
Rails is used on many production sites, succesfully and stable. The
only time it chokes is when I do something stupid.

And each release since 1.0 has been 100% backwards compatible.

Mark wrote:

wrong number of arguments (1 for 0)

8: <%= post.created_at.to_s(:long) %>

Only the Time and Date classes have a parameter that can be passed to
the to_s method. I think your database is not returning a Time object.
Try this to troubleshoot.

change line #8 to:
<%= post.created_at.class %>

This should render out “Time” if it doesn’t, you have the wrong datatype
set on that database column. Change the database column data type to
“datetime” (on mysql, not sure of others) and it should work fine.

The basic logic here is that if the to_s method does not take a
parameter, that the object it’s called on is not a date.

Though polymorphism is powerful, it can be tricky at times.

Hi Alex,

Thank you for taking the time to reply.

I did exactly as you described and got quite an odd response:


My wonderful weblog
Oi

Tudo bem?

NilClass (Edit)
Hello

How are you?

Time (Edit)
New post

  • I added The *'s around the printed class.

It seems the first time the template is used it said that the class is
of type “NilClass”… Great, we found the bug… but… the second
instance it says the class is a “Time” class as we expect, I check the
database and sure enough it is a datetime field, and checking the value
through the database view it is “0000-00-00 00:00:00” not initialized
(because I added the created_at field after the first entry. So it seems
that if there is data in the field it knows that it’s a datetime field,
but if not, it doesn’t know the type. Is this normal?

Alex W. wrote:

Mark wrote:

wrong number of arguments (1 for 0)

8: <%= post.created_at.to_s(:long) %>

Only the Time and Date classes have a parameter that can be passed to
the to_s method. I think your database is not returning a Time object.
Try this to troubleshoot.

change line #8 to:
<%= post.created_at.class %>

This should render out “Time” if it doesn’t, you have the wrong datatype
set on that database column. Change the database column data type to
“datetime” (on mysql, not sure of others) and it should work fine.

The basic logic here is that if the to_s method does not take a
parameter, that the object it’s called on is not a date.

Though polymorphism is powerful, it can be tricky at times.

Hey Mark, I had the same problem as you.

Here’s the fix:

Replace:
<%= post.created_at.to_s(:long) %>

With:
<%= post.created_at %>

Then just edit one of ur posts so that the date and time are refreshed.