Created
May 17, 2012 14:56
-
-
Save regedarek/2719479 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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