-
Notifications
You must be signed in to change notification settings - Fork 98
Model.last method added like in ActiveRecord in Rails framework #100
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,7 @@ def execute | |
return results.to_i | ||
else | ||
results = JSON.parse(resp)['results'] | ||
puts results | ||
return results.map {|r| @klass.model_name.to_s.constantize.new(r, false)} | ||
end | ||
end | ||
|
@@ -137,6 +138,13 @@ def first | |
execute.first | ||
end | ||
|
||
#my contribution | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this comment. |
||
def last | ||
order('created_at desc') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if you don't want to order by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. If this method were to be added it would need to take some kind of option param to allow users to return the |
||
limit(1) | ||
execute.last | ||
end | ||
|
||
def all | ||
execute | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldnt be left here