2015-01-23 4 views
0

나는 버전 3.2.19유형 오류를 해결하는 방법은 무엇입니까?

오류를 레일을 사용하고 있습니다 :

TypeError in UsersController#create 

can't convert Symbol into String 
Rails.root: C:/Site/myapp1 

Application Trace | Framework Trace | Full Trace 
app/controllers/users_controller.rb:25:in `user_params' 
app/controllers/users_controller.rb:12:in `create' 

이 내 코드 조각은 다음과 같음.

인/사용자/index.html.erb

<center> 
    <h1>Select your option</h1> 
    <p> 
    <%= link_to "Register here",users_new_path %> 
    </p> 
    <p> 
    <%= link_to "Display your data",users_show_path %> 
    </p> 
</center> 

인/사용자/new.html.erb

<h1>Enter your data</h1> 
<center> 
    <%= form_for :user,:url => {:action => 'create'} do |f| %> 
     <% if @user.errors.any? %> 
      <div id="errorExplanation"> 
      <h2><%= pluralize(@user.errors.count, "error") %> prohibited 
       this post from being saved:</h2> 
      <ul> 
       <% @user.errors.full_messages.each do |msg| %> 
        <li><%= msg %></li> 
       <% end %> 
      </ul> 
      </div> 
     <% end %> 

     <p> 
     <%= f.label :Name %> 
     <%= f.text_field :name,placeholder:"Enter your name" %> 
     </p> 
     <p> 
     <%= f.label :Email %> 
     <%= f.email_field :email,placeholder:"Enter your email" %> 
     </p> 
     <p> 
     <%= f.label :content %> 
     <%= f.text_area :content %> 
     </p> 
     <p> 
     <%= f.submit "Create" %> 
     </p> 
    <% end %> 
</center> 

제어기/users_controller.rb

class UsersController < ApplicationController 
    def index 

    end 
    def new 
    @user=User.new 
    end 
    def show 

    end 
    def create 
    @user=User.new(user_params) 
    if @user.save 
     flash[:notice]="User has created successfully" 
     flash[:color]="valid" 
     redirect_to :action => 'index' 
    else 
     flash[:alert]="User did not create" 
     flash[:color]="invalid" 
     render :new 
    end 
    end 
    private 
    def user_params 
    params.require(:user).permit(:name, :email,:content) 
    end 
end 

모델/

class User < ActiveRecord::Base 
    attr_accessible :content, :email, :name 
    EMAIL_REGEX = /\A[A-Z0-9._%+-][email protected][A-Z0-9.-]+\.[A-Z]{2,4}\z/i 
    validates :name, :presence => true, :uniqueness => true, :length => { :in => 3..20 } 
    validates :email, :presence => true, :uniqueness => true, :format => EMAIL_REGEX 
end 

내가 위의 오류를 얻을 버튼을 만들에 내가 클릭 user.rb. 이 오류를 해결하는 데 도움주세요.

+0

그것에 대해 더 많은 정보를 찾을 수 있습니까? – hakcho

답변

관련 문제