Skip to content

Instantly share code, notes, and snippets.

@regedarek
Created May 17, 2012 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save regedarek/2719479 to your computer and use it in GitHub Desktop.
Save regedarek/2719479 to your computer and use it in GitHub Desktop.
# Suitcase < Gem za pomoca ktorego mam dostep do API
class Search < ActiveRecord::Base
attr_accessible :headed, :children, :localization, :arriving_date, :leaving_date, :rooms, :adults
def hotels
@hotels ||= find_hotels
end
private
def find_hotels
hotels = Suitcase::Hotel.find(location: "%#{headed}%") if headed.present?
end
end
class SearchesController < ApplicationController
require 'will_paginate/array'
def new
@search = Search.new
render :new, :layout => 'landing'
end
def create
@search = Search.create!(params[:search])
redirect_to @search
end
def show
@search = Search.find(params[:id])
@hotels = @search.hotels.paginate(:page => params[:page], :per_page => 6)
end
end
<h2>Hotels in New York City</h2>
...
<p class="crop">
<img src="<%= Suitcase::Hotel.find(id: hotel.id).images.first.url %>" alt="css template" />
</p>
</div>
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment