Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add radio #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions app.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'bundler/setup'
require 'open-uri'
require 'pry'


Bundler.require(:default)
Expand Down Expand Up @@ -55,17 +56,6 @@
erb(:login)
end

post '/login' do
email = params['email']
password = params['password']
user = User.find_by_email(email)
if BCrypt::Password.new(user.password) == password
redirect("/user/#{user.id}")
else
erb(:login)
end
end

get '/user/:id' do
@all = []
@search = []
Expand Down Expand Up @@ -124,7 +114,7 @@
elsif params['sqft'] != ''
combined_search = "sqft > #{params['sqft']}"
end
@search = Apartment.where(combined_search).order(:price)
@search = Apartment.where(combined_search).order(params['sort'])
@all = Apartment.all
erb(:user)
end
Expand Down
21 changes: 20 additions & 1 deletion views/user.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<div class="container">
<form action="/user/<%= @user.id %>" method="post">
<h1>Search Criteria:</h1>
<h3>Important: Leave a input blank if you do not wish to search by those parameters</h3>
<h3>Important: Leave an input blank if you do not wish to search by those parameters</h3>

<h4>Bedrooms:</h4>
<div class='form-group'>
Expand Down Expand Up @@ -96,7 +96,23 @@

<label for="sqft">Enter Min Sqare Feet</label>
<input type="number" name="sqft"><br>
<!-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -->
<h4>Sort By:</h4>
<div>
<input type="radio" name="sort" value="price" checked>
<label for="contactChoice1">Price</label>

<input type="radio" name="sort" value="bed">
<label for="contactChoice2">Bed</label>

<input type="radio" name="sort" value="bath">
<label for="contactChoice2">Bath</label>

<input type="radio" name="sort" value="sqft">
<label for="contactChoice2">Sqft</label>
</div>

<!-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -->
<button type="submit">Search</button>
</form>

Expand Down Expand Up @@ -194,6 +210,9 @@ function toggle3(source) {
checkboxes[i].checked = source.checked;
}
}
// xxxxxxxxxxxxxxxxxx

// xxxxxxxxxxxxxxxxxx
</script>

</body>