خرید بک لینک

Vote count: 0

I am trying to lea how to use routes and paths in Rails 4.

I have a model called organisation requests.

I have routes in by routes.rb as follows:

resources :organisation_requests do #, only: [ :index, :new, :create ]
    member do 
      put "requested" => "organisation_requests#requested", as: :request_approval #what does this mean?
      put "approved" => "organisation_requests#requested", as: :approved #what does this mean?
      put "rejected" => "organisation_requests#rejected", as: :not_approved #what does this mean?
      put "removed" => "organisation_requests#removed", as: :removed #what does this mean?
    end
  end

In my organisation requests controller, I have:

 def approved
    organisation_request = OrganisationRequest.find(params[:id])
    authorize @organisation_request
    if organisation_request.state_machine.transition_to!(:approved)
      flash[:notice] = "You've been added as a member. Welcome aboard."
      format.html { redirect_to :index }
      # format.json { render :show, status: :ok, location: @project }
      # redirect_to action: :show, id: project_id
      # add mailer to send message to owner that article has been approved
    else
      flash[:error] = "You're not able to manage this organisation's members"
      redirect_to(profile_path(current_user.profile))
      # redirect_to action: :show, id: project_id
    end
  end

In my organisation requests index, I'm trying to make a path that allows a user to approve a request:

<% @organisation_requests.each do |orgReq| %>

              <tr>
                <td>
                  <%#= link_to orgReq.profile.user.full_name, organisation_request.profile_path(organisation_request.profile.id) %>
                </td>
                <td>
                  <%= orgReq.created_at.try(:strftime, '%e %B %Y') %>
                </td>
                <td>
                  <%= orgReq.current_state %>
                </td>
                <td>
                  <% if policy(orgReq).approved? %>    
                      <%= link_to "APPROVE", request_approval_path(@organisation_request), :class=>'btn btn-info', method: :put %>
                  <% end %>


                </td>  

              </tr> 
            <% end %> 

When I save all this and try it, I expect the approve button to work. Instead I get an error that says:

undefined method `request_approval_path' for #<#<Class:0x007fa470f72968>:0x007fa474d17a98>

I'm not sure where I'm going wrong?

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 12 مرداد 1395 ساعت: 7:17

صفحه بندی