Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## What I'm trying to do
- From the Contacts page, I want to have a link_to
- that takes a user to a static web site that is located
- at /Agreements/show_user.html.erb.
- This is a temporary landing page until I get a chance
- to work out the code.
- ## How I went about it.
- - created def show_us in the agreements controller
- - created show_user.index.erb in the agreements view
- - created the link_to in the contacts/show.index.erb
- ## What I get
- ActiveRecord::RecordNotFound in AgreementsController#show
- Couldn't find Agreement with ID=show_user
- RAILS_ROOT: /home/andrew/RubymineProjects/ocpoc
- ## from Contacts/show.index.erb
- <%= link_to 'Next -> Agreements', '/agreements/show_user' %>
- ## agreements_controller
- class AgreementsController < ApplicationController
- # GET /agreements
- # GET /agreements.xml
- def index
- end
- def show_user
- end
- # GET /agreements/1
- # GET /agreements/1.xml
- def show
- @agreement = Agreement.find(params[:id])
- respond_to do |format|
- format.html # show.html.erb
- format.xml { render :xml => @agreement }
- end
- end
- # GET /agreements/new
- # GET /agreements/new.xml
- def new
- @agreement = Agreement.new
- respond_to do |format|
- format.html # new.html.erb
- format.xml { render :xml => @agreement }
- end
- end
- # GET /agreements/1/edit
- def edit
- @agreement = Agreement.find(params[:id])
- end
- # POST /agreements
- # POST /agreements.xml
- def create
- @agreement = Agreement.new(params[:agreement])
- respond_to do |format|
- if @agreement.save
- flash[:notice] = 'Agreement was successfully created.'
- format.html { redirect_to(@agreement) }
- format.xml { render :xml => @agreement, :status => :created, :location => @agreement }
- else
- format.html { render :action => "new" }
- format.xml { render :xml => @agreement.errors, :status => :unprocessable_entity }
- end
- end
- end
- # PUT /agreements/1
- # PUT /agreements/1.xml
- def update
- @agreement = Agreement.find(params[:id])
- respond_to do |format|
- if @agreement.update_attributes(params[:agreement])
- flash[:notice] = 'Agreement was successfully updated.'
- format.html { redirect_to(@agreement) }
- format.xml { head :ok }
- else
- format.html { render :action => "edit" }
- format.xml { render :xml => @agreement.errors, :status => :unprocessable_entity }
- end
- end
- end
- # DELETE /agreements/1
- # DELETE /agreements/1.xml
- def destroy
- @agreement = Agreement.find(params[:id])
- @agreement.destroy
- respond_to do |format|
- format.html { redirect_to(agreements_url) }
- format.xml { head :ok }
- end
- end
- end
- ## model for agreements
- class Agreement < ActiveRecord::Base
- belongs_to :user
- end
Add Comment
Please, Sign In to add comment