Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my index.html.erb
<% @methodtypes.each do|m| %>
  <tr>
    <td><%=m.name %></td>
    <td><%=m.desp %></td>
  </tr>
  <%= link_to "Edit", edit_method_types_path(m.id) %>
<% end %>
<%= link_to "Create Method", new_method_types_path %>




This is my edit.html.erb:
<%= form_for @methodtype do |f| %>
  <div>
    <%= f.label :name %>
    <%= f.text_area :name %>
  </div>
  <div>
    <%= f.label :desp %>
    <%= f.text_field :desp %>
  </div>

  <%= f.submit %>

<% end %>


This is my controller which is called method_types_controller.rb:
class MethodTypesController < ApplicationController
	def index
		@methodtypes = MethodType.all

	end

	def show
		@methodtype = MethodType.find_by_id(params[:id])
	end



	def create
		@methodtype = MethodType.new(method_params)
		@methodtype.save
		if @methodtype.save
			redirect_to  method_types_path
		else
			render :new
		end
	end

	def delete
	end 

	def destroy

	end

	def edit
		@methodtype = MethodType.find_by_id(params[:id])
	end



	def new
		@methodtype = MethodType.new
	end 




private
	def method_params
	        params.require(:method_type).permit(:name, :desp)
	end

end


What I have tried:

I have tried put m.id or m into index.html.erb. But it still does not correct.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900