...notice that the filters do no longer apply, routes are broken and the necessary parameters are no longer extracted. That is because routing-filter patches Rails' find_routes-method to...

...current path and apply its defined filters on it. These filters then modify the params that are handed over to your controller action. This way you receive a locale parameter...

makandra dev
select2.org

...the load. Select2 supports an "infinite scroll" feature, which will be enabled with a params.page property in the request and a pagination.more value in the response. I would also recommend...

} ], "pagination": { "more": true } } Basic ajax options $('#mySelect2').select2({ ajax: { url: , data: function (params) { return { query: params.term, page: params.page || 1 } } processResults: function (data, params) { return data }, } }); Further reading...

makandra dev
github.com

...method can be used to preload associations for loaded objects like this: @user = User.find(params[:id]) User.preload_associations [@user], { :threads => { :posts => :author }, :messages => :sender } Useful in libraries These utilities are...

makandra dev

...application stack. Be aware that no hooks like authentication will be invoked and no parameters will be taken into consideration for cache key generation! If there aren't any params...

...can use the :cache_path option to generate a cache id that takes the params hash or your session data into consideration. The following example demonstrates how you could include...

...posts.reindex # this is not async, but we have workarounds! end end end Suche: Searchkick.search(params[:query].to_s, models: [Post, Message, Document], page: params[:page], per_page: 20).to_a...

api.rubyonrails.org

...the others) comes with an initializer wrap_parameters.rb. Here you can tell rails to wrap parameters send to your controllers for specific formats into a root node which it guesses from...

...the controller name. ActiveSupport.on_load(:action_controller) do wrap_parameters format: [:json] end This would wrap a flat json body, like {"name": "Konata"} that gets send to your UsersController into...

...on attribute :teh_image end And these controllers: class GalleryController < ApplicationController # ... private def gallery_params params.require(:gallery).permit [:name, { images_attributes: [:id, :caption, :_destroy, :teh_image_cache] }] end end

...UploadsController < ApplicationController def gallery_image image = params.require(:gallery).require(:add_images).first uploader = Image.new.teh_image uploader.cache! image # Return the image's cache name to the client render json: uploader.cache_name...

Typhoeus has a different way of representing array params in a get request than RestClient. Typhoeus: http://example.com/?foo[0]=1&foo[1]=2&foo[2]=3 RestClient: http://example.com/?foo[]=1&foo[]=2&foo[]=3 Webmock normalizes this url when matching to...

...It was possible to use .where or .create_with to bypass Rails' Strong Parameters: user.blog_posts.create_with(params[:blog_post]).create would set all attributes on the blog post. After the...

...fix, you have to properly whitelist the params, via params[:blog_post].permit(:title, :body). If you did not even know .create_with existed, have a look at the API...

...the other database(s) by specifying the ActiveRecord ORM together with an additional db parameter. The db param however is not the name of your database, but the name of...

DatabaseCleaner[:active_record].strategy = :transaction` You can see that there is no db parameter. When you omit that parameter, DatabaseCleaner will fallback to ActiveRecord::Base as connection base in...

...Rails tries to retrieve 'makandra' with format 'html-username-2000' Just restrict accepted format parameters for the whole application like this: class ApplicationController < ActionController::Base before_filter :refuse_silly_formats...

def refuse_silly_formats acceptable_formats = %w[html xml pdf] if params[:format] unless acceptable_formats.include? params[:format].downcase Rails.logger.error "Format not supported: #{params[:format]}" head interpret_status(:not_acceptable...

OAuth requires a set of params to be carried along requests, among which a nonce. Some libraries pass these along as headers, some as query parameters. All fine.

...match these requests with VCR. Solution Obviously you need to ignore those variable OAuth params. To do so, add a custom request matcher: # spec/support/vcr.rb or wherever you need it

To upload a file via AJAX (e.g. from an ) you need to wrap your params in a FormData object. You can initialize a FormData using the contents of a form...

...var formData = new FormData(form); // Wrap form contents Or you can construct it manually, param by param: var fileInput = document.querySelector('form input[type=file]'); var attachment = fileInput.files[0];

...as the screen medium. The step belows reloads the current page with a query param we will use in our layout to load the print stylesheet even if the medium...

...visit "#{current_path}?medium=print" end Here's the switch in our layout: - if params[:medium] == 'print' = stylesheet_link_tag "print", :media => "screen" - else = stylesheet_link_tag "screen", :media => "screen...

...on saving the object caused by the random order of hash elements of the params hash. class Feedback belongs_to :user def role=(value) @role = value self.email = find_email_by...

...name(user.name) end end This piece of code works well until the object params hash contains a second element when it is updated like this: @feedback.update_attributes!(params[:feedback])

...have the following deprecation warning after upgrading to rails >= 2.3.10 DEPRECATION WARNING: The :overwrite_params option is deprecated. Specify all the necessary parameters instead. that is for example caused by...

...url_for( :overwrite_params => { :order => 'name', :dir => 'asc' } ) you can fix this by using params.merge {:my_param_to_overwrite => 'foo' }. To fix the example above the code could look like...

...attribute should contain integer values you might get unexpected behavior with forms, because every param is a string and you don't get the magic type casting that Rails would...

...you have form roundtrips due to validation errors, boxes "forget" their values because all params are strings and "123" does not match 123. A wonderful way to get virtual attributes...

class ArticlesController < ApplicationController def index articles = visible_articles articles = articles.chain_safely.for_users(params[:user_id_filter]) if params[:user_id_filter] end private def visible_articles current_user.articles

...as => :note_scope def show load_note end private def load_client @client ||= client_scope.find(params[:client_id]) end def load_note @note ||= note_scope.find(params[:id]) end end

...provide the Client parameter for the :client_notes power by using the :context => :load_client option in the power directive...

svnweb.freebsd.org

...in 373485. If you get errors looking like this one: ===> Registering installation for p5-Params-Util-1.07_1 as automatic pkg-static: lstat(/usr/ports/devel/p5-Params-Util/work/stage/usr/local/./usr/local/lib/perl5/site_perl/mach/5.16/auto/Params/Util/.packlist): No such file or directory

makandra dev

...injector and asks it for the $state service. Inspecting the current state $state.current Inspecting params of the current state

...avoid them in general). We didn't use JSON:API and just wrapped the params like in Rails applications with forms (warp_params will do that for you). But maybe...

if [ -z "$1" ] then title=${PWD##*/} # current directory else title=$1 # first param fi echo -n -e "\033]0;$title\007" } Put it into your ~/.bashrc to have...

jqueryui.com

...position_15 will be turned into position[]=13&position[]=15, which neatly resolves to params[:position] == [13, 15] in Rails. Broken placeholder height When a dragged row does not have...