Skip to main content
user229044's user avatar
user229044's user avatar
user229044's user avatar
user229044
Moderator
  • Member for 16 years, 1 month
  • Last seen this week
comment
Rails: Get next / previous record
This is not at all how this is done. Your solution will load the entire set of IDs from the database, when it is only interested in two: The current ID, and the ID after or before it. What if there are 10,000,000 records? You'll create an array of 10 million integers, when all you need are two. You should absolutely not implement this as a select id from [table] order by [whatever] and process the entire table in Ruby, when a simple select * from [table] where id > [current] order by [whatever] limit 1 does the same job and returns a single record.
awarded
comment
Unexpected conversion from pointer to object during function call
Note that, if I make all the changes you're suggesting (correcting several typos) to the OP's code, their code still does the exact same thing (calls st(st *source)) and ignores all of your additions. If you have a specific fix here, I think you need to provide additional compilable code that demonstrates how your suggestion applies to OP.
comment
Unexpected conversion from pointer to object during function call
Why do they need to provide a copy constructor when the intent is to pass a const reference? There should be no copying here.
revised
How do I add a line break for read command?
deleted 48 characters in body
Loading…
awarded
revised
Loading…
comment
Why does my JavaScript code receive a "No 'Access-Control-Allow-Origin' header is present on the requested resource" error, while Postman does not?
That's not really what CORS does. Anybody can connect to the server, with or without CORS, from any system they control. The point of CORS is to restrict how people can instruct your browser to connect to a service from a (hostile) website they control, and if/how they can review how the service responds.
awarded
awarded
comment
Handle an array as a Ruby method would
@Stefan Love to see a monkeypatch needlessly polluting Hash with a method whose name is longer than its entire implementation.
answered
Loading…
revised
Loading…
revised
Loading…
awarded
awarded
revised
Loading…
revised
using git for images
deleted 1 character in body
Loading…
1
2 3 4 5
1323