Ruby – Simple search using DataMapper and Sinatra

I am generally new to Ruby and backend development. That being said, I am trying to create a simple search form. I use Sinatra as the framework and Datamapper as my ORM .What is the best way to do this? Below is my architecture. I want the search operation to search for tiles and categories at the same time.

require'sinatra'
require'datamapper'
< br />
DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/cal.db")

class Event
include DataMapper::Resource

property :id, Serial
property :title, String
property :text, Text
property :contact_name, String
property :contact_email, String< br /> property :location, String
property :event_start_time, String
property :event_end_time, String
property :category, String
property :created_at, DateTime
property: approved, Boolean, :default => false

end

DataMapper.auto_upgrade!


post'/search' do
@results = Event.all
erb :layout
end

============
layout.erb

< p>







<% if @results %>

<%@ results.each do |r|%>



<%end%>
<%=r.title%>

<% end %>

The most basic search query might look like this:

@events = Event.all(:title.like => "%#{params[ :query]}%") | Event.all(:category.like => "%#{params[:query]}%")

Back-end development are generally newbies. Having said that, I am trying to create a simple search form. I use Sinatra as the framework and Datamapper as my ORM. What is the best way to do this? Below is my architecture. I want the search operation to search for tiles and categories at the same time.

require'sinatra'
require'datamapper'
< br />
DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/cal.db")

class Event
include DataMapper::Resource

property :id, Serial
property :title, String
property :text, Text
property :contact_name, String
property :contact_email, String< br /> property :location, String
property :event_start_time, String
property :event_end_time, String
property :category, String
property :created_at, DateTime
property: approved, Boolean, :default => false

end

DataMapper.auto_upgrade!


post'/search' do
@results = Event.all
erb :layout
end

============
layout.erb

< p>







<% if @results %>

<%@results. each do |r|%>



<%end%>
<%=r.title%>

<% end %>

The most basic search query might look like this:

@events = Event.all(:title.like => "%#{params[:query]}%") | Event.all(:category .like => "%#{params[:query]}%")

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3282 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.