js-rails-as-api-extracting-a-service-class's Issues
Suggestion for cleaner way to write @sighting.to_json
Hi! In this lab and the previous lab, there's a few mentions of how difficult it is to write/read the lab's @sighting.to_json
call:
@sighting.to_json(:include => {
:bird => {:only => [:name, :species]},
:location => {:only => [:latitude, :longitude]}
}, :except => [:updated_at])
If I can, I'd like to suggest a cleaner way to write this:
@sighting.to_json(
include: {
bird: { only: [ :name, :species ] },
location: { only: [ :longitude, :latitude ] }
},
except: [ :updated_at ]
)
typo in code
unnecessary , after :except => {...}...
this:
def to_serialized_json
options = {
include: {
bird: {
only: [:name, :species]
},
location: {
only: [:latitude, :longitude]
}
},
except: [:updated_at],
}
@sighting.to_json(options)
end
should be:
def to_serialized_json
options = {
:include => {
:bird => {
:only => [:name, :species]
},
:location => {
:only => [:latitude, :longitude]
}
},
:except => [:updated_at]
}
@sighting.to_json(options)
end
This lab uses @sighting in SightingsController when only local is required
Hi! Quick note: SightingsController
in this lab is using @sighting
even though we've said in previous labs that only local variables are required, and used in the README. The same happens in the previous labs, @instance variables are being used in the actual lab code rather than local variables.
README leads to Ruby NameError: Uninitialized Constant
In app/controllers/sightings_controller.rb
, I needed to include the line require "./services/sighting_serializer.rb"
in order for Rails to read the code in app/services/sighting_serializer.rb
. A NameError results if the require
line is not included. I believe a student will encounter a Rails error if they follow the README exactly.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.