params

Include params/request information in Rails logger?

六月ゝ 毕业季﹏ 提交于 2019-11-28 20:36:14
问题 I'm trying to get some more information into my Rails logs, specifically the requested URI or current params, if available (and I appreciate that they won't always be). However I just don't seem able to. Here's what I've done so far: #config/environments/production.rb config.logger = Logger.new(config.log_path) config.log_level = :error config.logger.level = Logger::ERROR #config/environment.rb class Logger def format_message(level, time, progname, msg) "**************************************

How can I make a check_box_tag to post a 'false' or '0' parameter when unchecked?

≯℡__Kan透↙ 提交于 2019-11-28 18:34:39
问题 With the following check_box_tag: <%= check_box_tag 'object[boolean_attribute]', 1, object.boolean_attribute %> I can update the boolean_attribute in only one direction: from false to true. When is unchecked by default (because object.boolean_attribute is false) and I check it and then submit the form, a :boolean_attribute => 1 parameter is posted. But , when I try to update from true to false no param is passed, so the boolean_attribute remains true. In other words, when is checked by

Is there a way to distingish myFunc(1, 2, 3) from myFunc(new int[] { 1, 2, 3 })?

喜夏-厌秋 提交于 2019-11-28 12:08:45
A question to all of you C# wizards. I have a method, call it myFunc, and it takes variable length/type argument lists. The argument signature of myFunc itself is myFunc(params object[] args) and I use reflection on the lists (think of this a bit like printf, for example). I want to treat myFunc(1, 2, 3) differently from myFunc(new int[] { 1, 2, 3 }) . That is, within the body of myFunc, I would like to enumerate the types of my arguments, and would like to end up with { int, int, int} rather than int[]. Right now I get the latter: in effect, I can't distinguish the two cases, and they both

how can I hide params I transmit to a method (like form_for seems to do)?

萝らか妹 提交于 2019-11-28 10:37:59
I've been searching for hours now and haven't found anything that helps. What I want to do: I need to call the check_login -Method (as below), which needs parameters. redirect_to check_login_users_url( :user => {:name => input[1], :password => input [2] }, :stylesheet => 'scaffold', :method => :get) The point is that these params are sent in the method-call as in the "Redirected to"-line below. Processing ApplicationController#execute(for 127.0.0.1 at 2009-12-19 00:28:40) [POST] Parameters: {"command"=>{"line"=>"log dodo wg"}, "authenticity_token"=> <...token>} Redirected to http://localhost

how to save array to database in rails

二次信任 提交于 2019-11-28 09:42:44
if i have params like this : params["scholarship"] = {"name"=>"test", "state_ids"=>["1", "2", "3", "4"]} and when i create object to database field state_id not save to database? how to save to database with format : #<Scholarship id: 1, name: "test", state_id: "["1", "2", "3", "4"]"> how do that? thanks before Rubyist ActiveRecord::Base.serialize . For example: class User < ActiveRecord::Base serialize :scholarship end user = User.create(:scholarship=> { "name" => "test", "state_ids" => ["1", "2"]}) User.find(user.id).scholarship# => { "name" => "test", "state_ids" => ["1", "2"] } Also you

How to use private submit to hide from profile?

不打扰是莪最后的温柔 提交于 2019-11-28 06:11:28
问题 When a User submits via private how can we hide the submitted info from the feed and from other users being able to see it on his public profile? <%= button_tag(type: 'submit', class: "btn") do %> ... <%= button_tag(type: 'submit', class: "btn", id: "2", name: 'private') do %> ... We put the below in the controller, but since the private button will be in a lot of different _forms, do I have to put it in each controller or can we put it in the application controller? if params[:private] # the

Passing an array as `params` argument

99封情书 提交于 2019-11-28 03:24:06
问题 I have the following method: void MyMethod(params object[] args) { } which I am trying to call with a parameter of type object[] : object[] myArgs = GetArgs(); MyMethod(myArgs); It compiles fine, but inside MyMethod I args == { myArgs} , i.e. an array with one element that is my original arguments. Obviously I wanted to have args = myArgs , what am I doing wrong? EDIT: Jon Skeet was actually right, the GetArgs() did wrap the thing in an one element array, sorry for stupid question. 回答1: What

Load AS2 SWF Into AS3 SWF and pass vars in URL

孤者浪人 提交于 2019-11-28 01:34:33
I've got an AS3 SWF that I'm going to be loading other SWFs into. These child SWFs all take a single parameter on the URL. I can't seem to get it working when loading an AS2 child, and it needs to be able to handle both. so I have var request:URLRequest = new URLRequest(); var loader:URLLoader = new URLLoader(); request.url = "http://domain/as2.swf?param=foo"; loader.load(request); // etc on to the eventListeners, addChild, etc When the as2 SWF gets loaded, it can't see the parameter I've passed to it. It's looking for _root.param. Am I doing this wrong or am I attempting the impossible? EDIT:

How to pass parameters to $http in angularjs?

大憨熊 提交于 2019-11-27 18:43:40
Assume that I have two input boxes with corresponding ng-model as fname and lname. If I call http request as : $http({method:'GET', url:'/search', params:{fname: fname, lname: lname}}) will it call to the url : /search?fname=fname&lname=lname The error I am getting at the backend(python) is : cannot concatenate str and nontype objects. Are these parameters not sent as strings? If not, how to get around with this? Here is how you do it: $http.get("/url/to/resource/", {params:{"param1": val1, "param2": val2}}) .then(function (response) { /* */ })... Angular takes care of encoding the parameters

Key value pair params handling in Backbone.js Router

人盡茶涼 提交于 2019-11-27 18:16:37
问题 I want to pass key value pairs as params to Backbone routes and want it to be deserialized to a javascript object before the mapped function is called. var MyRouter = Backbone.Router.extend({ routes: { "dashboard?:params" : "show_dashboard" }, show_dashboard: function(params){ console.log(params); } }); When I go to "http://...#dashboard?key1=val1&key2=val2", then {key1: "val1", key2: "val2"} should be printed on the console. Am currently using jQuery BBQ's $.deparam method inside each mapped