Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def index
- if (params[:commit])
- min = params[:price].match(/.*?(\d+).*?\d+/).captures.first.to_i
- max = params[:price].match(/.*?\d+.*?(\d+)/).captures.first.to_i
- @listings = Listing
- @listings = @listings.where(:author => params[:author]) unless params[:author].blank?
- @listings = @listings.where(:price => min..max ) unless params[:price].blank?
- @listings = @listings.where(:condition => params[:condition]) unless params[:condition].blank?
- @listings = @listings.where("created_at > ?", params[:age].to_i.seconds.ago ) unless params[:age].blank?
- else
- @listings = Listing.all
- end
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @listings }
- end
- end
- def manage
- if (params[:commit])
- min = params[:price].match(/.*?(\d+).*?\d+/).captures.first.to_i
- max = params[:price].match(/.*?\d+.*?(\d+)/).captures.first.to_i
- @listings = Listing.where(:author => current_user.email)
- @listings = @listings.where(:author => params[:author]) unless params[:author].blank?
- @listings = @listings.where(:price => min..max ) unless params[:price].blank?
- @listings = @listings.where(:condition => params[:condition]) unless params[:condition].blank?
- @listings = @listings.where("created_at > ?", params[:age].to_i.seconds.ago ) unless params[:age].blank?
- else
- @listings = Listing.where(:author => current_user.email)
- end
- render :action => "index"
- end
Add Comment
Please, Sign In to add comment