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

Model.last method added like in ActiveRecord in Rails framework #100

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Model.last method added like in ActiveRecord in Rails framework #100

wants to merge 3 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Nov 28, 2013

I am going to put this pull request to add a new method Mode.last to get the last row in table just like it is available in Active Record ORM.

@@ -137,6 +138,13 @@ def first
execute.first
end

#my contribution
def last
order('created_at desc')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you don't want to order by created_at?

Copy link
Collaborator

Choose a reason for hiding this comment

The 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 last object sorted by a field they specify

@jamonholmgren
Copy link
Collaborator

I'd recommend against merging. Ordering by created_at is unintuitive.

@adelevie
Copy link
Owner

Thanks for the PR. I'll take a little more time to review it, but I think @jamonholmgren has a good point. Also, there are some files that need to be checked out of the PR.

@ghost
Copy link
Author

ghost commented Dec 2, 2013

Actually in ActiveRecord, it gives us a function model.last which returns the last row of the table. Keeping that in mind, I have worked on this.

@@ -108,6 +108,7 @@ def execute
return results.to_i
else
results = JSON.parse(resp)['results']
puts results
Copy link
Collaborator

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

@cpjolicoeur
Copy link
Collaborator

None of the netbeans project files should be included

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants