Guest User

Untitled

a guest
Jul 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. ## What I'm trying to do
  2.  
  3. From the Contacts page, I want to have a link_to
  4. that takes a user to a static web site that is located
  5. at /Agreements/show_user.html.erb.
  6.  
  7. This is a temporary landing page until I get a chance
  8. to work out the code.
  9.  
  10. ## How I went about it.
  11.  
  12. - created def show_us in the agreements controller
  13. - created show_user.index.erb in the agreements view
  14. - created the link_to in the contacts/show.index.erb
  15.  
  16. ## What I get
  17.  
  18. ActiveRecord::RecordNotFound in AgreementsController#show
  19.  
  20. Couldn't find Agreement with ID=show_user
  21.  
  22. RAILS_ROOT: /home/andrew/RubymineProjects/ocpoc
  23.  
  24. ## from Contacts/show.index.erb
  25. <%= link_to 'Next -> Agreements', '/agreements/show_user' %>
  26.  
  27. ## agreements_controller
  28.  
  29. class AgreementsController < ApplicationController
  30. # GET /agreements
  31. # GET /agreements.xml
  32. def index
  33.  
  34. end
  35.  
  36. def show_user
  37.  
  38. end
  39.  
  40. # GET /agreements/1
  41. # GET /agreements/1.xml
  42. def show
  43. @agreement = Agreement.find(params[:id])
  44.  
  45. respond_to do |format|
  46. format.html # show.html.erb
  47. format.xml { render :xml => @agreement }
  48. end
  49. end
  50.  
  51. # GET /agreements/new
  52. # GET /agreements/new.xml
  53. def new
  54. @agreement = Agreement.new
  55.  
  56. respond_to do |format|
  57. format.html # new.html.erb
  58. format.xml { render :xml => @agreement }
  59. end
  60. end
  61.  
  62. # GET /agreements/1/edit
  63. def edit
  64. @agreement = Agreement.find(params[:id])
  65. end
  66.  
  67. # POST /agreements
  68. # POST /agreements.xml
  69. def create
  70. @agreement = Agreement.new(params[:agreement])
  71.  
  72. respond_to do |format|
  73. if @agreement.save
  74. flash[:notice] = 'Agreement was successfully created.'
  75. format.html { redirect_to(@agreement) }
  76. format.xml { render :xml => @agreement, :status => :created, :location => @agreement }
  77. else
  78. format.html { render :action => "new" }
  79. format.xml { render :xml => @agreement.errors, :status => :unprocessable_entity }
  80. end
  81. end
  82. end
  83.  
  84. # PUT /agreements/1
  85. # PUT /agreements/1.xml
  86. def update
  87. @agreement = Agreement.find(params[:id])
  88.  
  89. respond_to do |format|
  90. if @agreement.update_attributes(params[:agreement])
  91. flash[:notice] = 'Agreement was successfully updated.'
  92. format.html { redirect_to(@agreement) }
  93. format.xml { head :ok }
  94. else
  95. format.html { render :action => "edit" }
  96. format.xml { render :xml => @agreement.errors, :status => :unprocessable_entity }
  97. end
  98. end
  99. end
  100.  
  101. # DELETE /agreements/1
  102. # DELETE /agreements/1.xml
  103. def destroy
  104. @agreement = Agreement.find(params[:id])
  105. @agreement.destroy
  106.  
  107. respond_to do |format|
  108. format.html { redirect_to(agreements_url) }
  109. format.xml { head :ok }
  110. end
  111. end
  112. end
  113.  
  114. ## model for agreements
  115.  
  116. class Agreement < ActiveRecord::Base
  117.  
  118. belongs_to :user
  119.  
  120. end
Add Comment
Please, Sign In to add comment