Rails: Preserving GET query string parameters in link_to
link_to ‘Link’, request.query_parameters.merge({:per_page => 20})
link_to ‘Link’, request.query_parameters.merge({:per_page => 20})
Here’s a list of tools that “ease the pain” when interacting with simple JDBC: Spring’s JdbcTemplate jOOQ (can be used with SQL strings as well – disclaimer: I work for the vendor) Apache DbUtils (which you’ve mentioned yourself) JDBI sql2o persism
The problem seems to have been introduced in the latest version of ruby, ruby 2.2.0. Try this experiment: in rails console/or irb: [1] pry(main)>File.expand_path (“./”) => “/users/xxxx/Sites/xxxx” and in the terminal window: ]$ pwd /users/xxxx/sites/xxxx See the different case? If you get that, then deep in the bowels of active support a regex goes south. … Read more
Use number_format(): if ($n < 1000000) { // Anything less than a million $n_format = number_format($n); } else if ($n < 1000000000) { // Anything less than a billion $n_format = number_format($n / 1000000, 3) . ‘M’; } else { // At least a billion $n_format = number_format($n / 1000000000, 3) . ‘B’; } I … Read more
The method helper_method is to explicitly share some methods defined in the controller to make them available for the view. This is used for any method that you need to access from both controllers and helpers/views (standard helper methods are not available in controllers). e.g. common use case: #application_controller.rb def current_user @current_user ||= User.find_by_id!(session[:user_id]) end … Read more
To start off I created a folder in my app directory called Helpers. Then within the Helpers folder I added files for functions I wanted to add. Having a folder with multiple files allows us to avoid one big file that gets too long and unmanageable. Next I created a HelperServiceProvider.php by running the artisan … Read more
multiline strings in python are delimited by ”’. you should write: o = ”’ What operation do you want to use : 1. Add 2. Subtract 3. Multiply 4. Divide 5. Square the first number 6. Square the second number 7. Calculate the power of the first number to the second number 8. Square root … Read more