Errors while running step 5.6

102 views
Skip to first unread message

Paolo Di Pietro

unread,
Oct 25, 2013, 10:15:49 AM10/25/13
to rubyonra...@googlegroups.com
Hi,
I received the following error while running the step 5.6 (I'm using both the edge and the legacy docs)

TypeError in PostsController#create

can't convert Symbol into String

Rails.root: /home/pdipietro/blog

Application Trace | Framework Trace | Full Trace
app/controllers/posts_controller.rb:19:in `post_params'
app/controllers/posts_controller.rb:8:in `create'
This error occurred while loading the following files:
   post



Has anyone an idea on how the thing should be changed?

Here is PostsController

class PostsController < ApplicationController
def new
end
def index
@posts = Post.all
end
def create
@post = Post.new(post_params)
@post.save
redirect_to @post
end

def show
@post = Post.find(params[:id])
end

private
def post_params
params.require(:post).permit(:title, :text)
end
end

TIA

Paolo

Ryan Bigg

unread,
Oct 26, 2013, 4:16:11 PM10/26/13
to rubyonra...@googlegroups.com
Hi Paolo,

Could you please put this application up on github so that we could take a look at it?

Thanks!


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Documentation" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-do...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-docs.
For more options, visit https://groups.google.com/groups/opt_out.

Paolo Di Pietro

unread,
Oct 28, 2013, 5:18:41 AM10/28/13
to rubyonra...@googlegroups.com

Ryan,

As I'm new, I shoudn't want to break anything!!!

Please, tell me how and where to add the application.

Thank you

Paolo

Ryan Bigg

unread,
Oct 28, 2013, 1:00:43 PM10/28/13
to rubyonra...@googlegroups.com
Paolo,

It's as simple as uploading a Git repository to GitHub. I don't think there's much you can do to break that. Start here and work your way through the bootcamp: https://help.github.com/articles/set-up-git

Paolo Di Pietro

unread,
Oct 28, 2013, 3:41:01 PM10/28/13
to rubyonra...@googlegroups.com
Ryan,

The application is on https://github.com/pdipietro/demoblog

let me know ....

Paolo
You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Documentation" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-docs/TuQ1FYIzk_M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rubyonrails-do...@googlegroups.com.

Harshal Bhakta

unread,
Oct 28, 2013, 6:17:33 PM10/28/13
to rubyonra...@googlegroups.com
Paolo,

Are you referring to below 2 getting started guides?


If yes, then both the guides that your are referring to are written for Rails 4. Your application is using Rails 3.2.14.

Check section "3.1 Installing Rails" => "If it says something like "Rails 4.0.0", you are ready to continue."

If you are learning Rails using the getting started guide I would suggest you upgrade your application to use Rails 4.0.0 for the best experience. If you get stuck you can also access the source code of the getting started guide @ https://github.com/rails/docrails/tree/master/guides/code/getting_started

You are facing the problem because of strong parameters. Strong parameters are by default a part of Rails 4.0.0 but not 3.2.14. If you want to use strong parameters in 3.2.14 you will have to use the gem "strong_parameters".

Harshal

Paolo Di Pietro

unread,
Oct 29, 2013, 6:04:46 PM10/29/13
to rubyonra...@googlegroups.com
Thank you Harshal,

I got this answer

pdipietro@neo4j-ubu64:~/blog$ gem list rails

*** LOCAL GEMS ***

rails (4.0.0, 3.2.14)

Now, how can I select the correct version to run?

TIA

Paolo

Harshal Bhakta

unread,
Oct 30, 2013, 2:35:07 AM10/30/13
to rubyonra...@googlegroups.com
"gem list rails" gives you a list of all the versions of Rails installed on your system. Your Rails application picks the version of Rails from the Gemfile.



Change "gem 'rails', '3.2.14'" to "gem 'rails', '4.0.0'" in your Gemfile. 
Also make sure that rest of your Gemfile matches the Gemfile from Rails guide to avoid further problems with the getting started guide.

Harshal

Paolo Di Pietro

unread,
Nov 1, 2013, 5:18:54 AM11/1/13
to rubyonra...@googlegroups.com
It runs! Thank you very much.

Paolo
Reply all
Reply to author
Forward
0 new messages