edwinmillan / lunch Goto Github PK
View Code? Open in Web Editor NEWlunch
lunch
We need to make sure that any particular user can only have 1 preference for a given restaurant. In other words, a User should not be able to 'Like' and 'Dislike' the same Restaurant, or, a User should not be able to "double" 'Like' a Restaurant.
This should be as simple as giving Preference a validates_uniqueness_of validation on restaurant_id, scoped to user_id ...
e.g., in the Preference model:
validates_uniqueness_of :restaurant_id, scope: :user_id
We need more tests!
NoMethodError in Preferences#new
Showing /Users/errinlarsen/Code/Rails/lunch/app/views/preferences/_form.html.erb where line #2 raised:
undefined method `likes' for #Preference:0x007fef1cfb06b8
Extracted source (around line #2):
1: <%= simple_form_for(@preference) do |f| %>
2: <%= f.input :likes %>
3: <%= f.input :dislikes %>
4: <%= f.button :submit %>
5: <% end %>
Trace of template inclusion: app/views/preferences/new.html.erb
Rails.root: /Users/errinlarsen/Code/Rails/lunch
Application Trace | Framework Trace | Full Trace
app/views/preferences/_form.html.erb:2:in block in _app_views_preferences__form_html_erb___1564734051096441712_70332480177420' app/views/preferences/_form.html.erb:1:in
_app_views_preferences__form_html_erb___1564734051096441712_70332480177420'
app/views/preferences/new.html.erb:8:in _app_views_preferences_new_html_erb___2804989799273048826_70332485700800' app/controllers/preferences_controller.rb:34:in
new'
Request
Parameters:
None
More TESTS!!!!
Your erb files might need to be converted a certain way, I'll leave this to you so you can verify that it works.
I think it would be beneficial to convert the views from ERB to HAML.
HAML is easier to read and, besides other benefits, would prevent you from ever forgetting to include a matching closing tag in your markup.
Showing /Users/errinlarsen/Code/Rails/lunch/app/views/preferences/_form.html.erb where line #1 raised:
undefined method `model_name' for NilClass:Class
Extracted source (around line #1):
1: <%= simple_form_for(@entry) do |f| %>
2: <%= f.input :likes %>
3: <%= f.input :dislikes %>
4: <%= f.button :submit %>
Trace of template inclusion: app/views/preferences/new.html.erb
Rails.root: /Users/errinlarsen/Code/Rails/lunch
Application Trace | Framework Trace | Full Trace
app/views/preferences/_form.html.erb:1:in _app_views_preferences__form_html_erb___1564734051096441712_70332485679300' app/views/preferences/new.html.erb:8:in
_app_views_preferences_new_html_erb___2804989799273048826_70332485700800'
app/controllers/preferences_controller.rb:34:in `new'
Request
Parameters:
None
I recommend RSpec
I noticed in commit 0464e76 that the rspec fails for the preferences controller. I believe it may be haml related. I could be completely wrong.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.