Add words controller with index and show actions
This commit is contained in:
		
							
								
								
									
										10
									
								
								app/controllers/words_controller.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								app/controllers/words_controller.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
class WordsController < ApplicationController
 | 
			
		||||
 | 
			
		||||
  def index
 | 
			
		||||
    @words = Word.all
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def show
 | 
			
		||||
    @word = Word.find_by_id(params[:id])
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										2
									
								
								app/helpers/word_helper.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								app/helpers/word_helper.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
			
		||||
module WordHelper
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										12
									
								
								app/views/application/_definitions.html.erb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								app/views/application/_definitions.html.erb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
<table>
 | 
			
		||||
  <tr>
 | 
			
		||||
    <td><b>Part of Speech</b></td>
 | 
			
		||||
    <td><b>Definition</b></td>
 | 
			
		||||
  </tr>
 | 
			
		||||
<% word.definitions.each do |definition| %>
 | 
			
		||||
  <tr>
 | 
			
		||||
    <td><b><%= definition.pos %></b></td>
 | 
			
		||||
    <td><%= definition.definition %></td>
 | 
			
		||||
  </tr>
 | 
			
		||||
<% end %>
 | 
			
		||||
</table>
 | 
			
		||||
@@ -19,7 +19,8 @@
 | 
			
		||||
<h1>Words</h1>
 | 
			
		||||
<% @words.each do |word| %>
 | 
			
		||||
  <h2><%= word.word %></h2>
 | 
			
		||||
 | 
			
		||||
  <%= render "application/definitions", word: word %>
 | 
			
		||||
  <!--
 | 
			
		||||
  <table>
 | 
			
		||||
    <tr>
 | 
			
		||||
      <td><b>Part of Speech</b></td>
 | 
			
		||||
@@ -32,4 +33,5 @@
 | 
			
		||||
    </tr>
 | 
			
		||||
  <% end %>
 | 
			
		||||
  </table>
 | 
			
		||||
  -->
 | 
			
		||||
<% end %>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								app/views/words/index.html.erb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								app/views/words/index.html.erb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
<% @words.each do |word| %>
 | 
			
		||||
  <p><%= link_to word.word, word %></p>
 | 
			
		||||
<% end %>
 | 
			
		||||
							
								
								
									
										3
									
								
								app/views/words/show.html.erb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								app/views/words/show.html.erb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
<h1><%= @word.word %></h1>
 | 
			
		||||
 | 
			
		||||
<%= render "application/definitions", word: @word %>
 | 
			
		||||
		Reference in New Issue
	
	Block a user