2010-06-11 2 views
1
나는 약간 편집 할 때 내가 "알 수없는 행동"오류 메시지가지고있어 내가 왜 알아낼 힘든 시간을했다

:레일 : 조치가 명확하게 지정 "알 수없는 행동"메시지

Unknown action 
No action responded to 11. Actions: bin, create, destroy, edit, index, new, observe_new, show, tag, update, and vote 

당신이 할 수있는을 Rails가 위 목록의 각 작업에 대해 언급했는지 확인하십시오. 그리고 제 형식으로 action = "update"를 지정했습니다. 빠른 답변을 때 form_tag 지원하지 않는다는 것입니다

edit.rhtml 

<h1>Editing tip</h1> 

<% form_tag :action => 'update', :id => @tip do %> 
    <%= render :partial => 'form' %> 

    <p> 
    <%= submit_tag_or_cancel 'Save Changes' %> 
    </p> 
<% end %> 

_form.rhtml 

<%= error_messages_for :tip %> 

<p><label>Title<br/> 
<%= text_field :tip, :title %></label></p> 

<p><label>Categories<br/> 
<%= select_tag('categories[]', options_for_select(Category.find(:all).collect {|c| [c.name, c.id] }, @tip.category_ids), :multiple => true) %></label></p> 

<p><label>Abstract:<br/> 
<%= text_field_with_auto_complete :tip, :abstract %></label></p> 

<p><label>Name: <br/> 
<%= text_field :tip, :name %></label></p> 

<p><label>Link: <br/> 
<%= text_field :tip, :link %></label></p> 

<p><label>Content<br/> 
<%= text_area :tip, :content, :rows => 5 %></label></p> 

<p><label>Tags <span>(space separated)</span><br/> 
<%= text_field_tag 'tags', @tip.tag_list, :size => 40 %></label></p> 

class TipsController < ApplicationController 
before_filter :authenticate, :except => %w(index show) 

    # GET /tips 
    # GET /tips.xml 
    def index 
    @tips = Tip.all 
    respond_to do |format| 
     format.html # index.html.erb 
     format.xml { render :xml => @tips } 
    end 
    end 

    # GET /tips/1 
    # GET /tips/1.xml 
    def show 
    @tip = Tip.find_by_permalink(params[:permalink]) 
    respond_to do |format| 
     format.html # show.html.erb 
     format.xml { render :xml => @tip } 
    end 
    end 

    # GET /tips/new 
    # GET /tips/new.xml 
def new 
    @tip = session[:tip_draft] || current_user.tips.build 
    end 

def create 
    #tip = current_user.tips.build(params[:tip]) 
    #tipMail=params[:email] 
    #if tipMail 
    # TipMailer.deliver_email_friend(params[:email], params[:name], tip) 
    # flash[:notice] = 'Your friend has been notified about this tip' 
    #end 

    @tip = current_user.tips.build(params[:tip]) 
    @tip.categories << Category.find(params[:categories]) unless params[:categories].blank? 
    @tip.tag_with(params[:tags]) if params[:tags] 

    if @tip.save 
     flash[:notice] = 'Tip was successfully created.' 
     session[:tip_draft] = nil 
     redirect_to :action => 'index' 
    else 
     render :action => 'new' 
    end 
    end 


    def edit 
    @tip = Tip.find(params[:id]) 
    end 

    def update 
    @tip = Tip.find(params[:id]) 
    respond_to do |format| 
     if @tip.update_attributes(params[:tip]) 
     flash[:notice] = 'Tip was successfully updated.' 
     format.html { redirect_to(@tip) } 
     format.xml { head :ok } 
     else 
     format.html { render :action => "edit" } 
     format.xml { render :xml => @tip.errors, :status => :unprocessable_entity } 
     end 
    end 
    end 


    def destroy 
    @tip = Tip.find(params[:id]) 
    @tip.destroy 

    respond_to do |format| 
     format.html { redirect_to(tips_url) } 
     format.xml { head :ok } 
    end 
    end 



def observe_new 
    session[:tip_draft] = current_user.tips.build(params[:tip]) 
    render :nothing => true 
    end 


end 

답변

0

:로 작용 친구들이 친절하게 누락 된 링크와 함께 나를 도울 수 있는지 궁금

... 여기

코드입니다 옵션을 사용하면 문자열을 경로로 전달할 수 있습니다. 좀 더 긴 대답은 모델 편집 양식에 form_tag를 사용하면 안되기 때문에 form_for를 사용해야합니다.

어떤 레일을 사용하고 있습니까? .rhtml은 꽤 오래된 레일 생성기가 .html.erb 파일을 제공해야합니다. 최근에 원격으로 볼 수 있다면 사용할 수 있어야합니다.

<% form_for @tip do |f| %> 
    <%= f.label :title, 'Title' %><br /> 
    <%= f.text_field %> 
    ... etc 
<% end %> 
관련 문제