Rails Not database model
Active::Model::Model
Not database model
Example) SearchKeyword
class SearchKeyword include ActiveModel::Model attr_accessor :keyword validates :keyword, presence: true end
Create Form for it
record_controller.rb
def keywd @search = Searchword.new # form end def keywd_process @search = Serrchword.new(params[:search_keyword]) if @search.valid? render text: @search.keyword else render text: @search.errors.full_messages[0] end end
View
<%= form_for @search, url: { action: :keywd_process } do |f| %> <%= f.text_field :keyword, size: 25 %> <%= f.submit 'Search' %> <% end %>