params

Rails - escaping backslashes in params causing havoc?

穿精又带淫゛_ 提交于 2019-12-08 06:47:49
问题 I have a form that passes the same parameters as the form before it: <%= form_tag({:controller => "workouts", :action => "random"}) do %> <%= hidden_field_tag :workout, params[:workout] %> <%= hidden_field_tag :time, params[:time] %> <%= submit_tag "Get Another", :class => 'btn' %> The first form works fine, the second form to "get another" gives me the error can't convert Symbol into Integer for this line: @equipment_ids = params[:workout][:equipment_ids].collect{|s| s.to_i} The params of

Rails “array” in xml to params

蹲街弑〆低调 提交于 2019-12-08 06:46:30
问题 I am designing a rails rest API that I would like to expose either as xml or json. In a specific action, I am submitting a collection of objects like this: curl -d "<posts><post><title>my title</title></post><post><title>second post</title></post></posts>" localhost:3000/posts -X POST I thought that this would be translated into > params[:posts] [{:title => "my title"}, {:title => "second post"}] Instead of that I get {:post => [{:title => "my title"}, {:title => "second post"}]} The question

PHP - session_set_cookie_params(), lifetime doesn't work

China☆狼群 提交于 2019-12-08 06:45:57
问题 As first, I know a lot questions are like mine, but I really don't know what I'm doing wrong... As you might've guessed, I've a PHP script involving sessions. Everything works like a charm, except setting the lifetime of my session. I want to keep the session active for two weeks, but instead my (Chrome) browser says it's set to xpire after the browsing session (and it does). My PHP script: session_name('DSWLogin'); // Naming the session session_set_cookie_params(2*7*24*60*60); // Making the

Nested attributes of uploaded image not being saved

拟墨画扇 提交于 2019-12-08 06:15:27
问题 I use Refile to attach images. Given the following models: class User < ActiveRecord::Base has_many :avatars, dependent: :destroy accepts_attachments_for :avatars, attachment: :file, append: true accepts_nested_attributes_for :avatars, :allow_destroy => true end class Avatar < ActiveRecord::Base belongs_to :user attachment :file end I have been trying to store the image metadata—in particular, the filename, size, and content type—in the database. To do this, I added the necessary columns to

Howto get a map from params in Grails Controller?

喜夏-厌秋 提交于 2019-12-08 03:40:03
问题 I'm trying to retrieve in the controller a complex object sent from the client (via ajax) in JSON format, but I don't know how to get from params the map in which are converted some of the properties. For example, imagine this is the "complex" JSON object (the number of items in the meta object is variable, could be one, two, three... and with variable names): { language: "java", meta: { category: "category1" } } When this object is sent via jQuery, in the controller I get this in params

How can I pass javascript variable to grails controller using remoteFunction

[亡魂溺海] 提交于 2019-12-08 02:11:51
问题 I am working with grails 2.1.1. I have a remote function from where I want to pass more than one java script variable through g:remoteFunction. But no js variable is going to controller. My js variables are underlined and are not recognized. Can anyone please help me on this please ?!!! Here are my attempts below :: My function >>> function addNewBill(){ var orgId = $('#aaOrgIdAaOrg').val(); var ccId = $('#costCenter').val(); if(orgId != null && orgId != "null" && orgId != "" && ccId != null

send variable to controller with link_to method rails 3

自闭症网瘾萝莉.ら 提交于 2019-12-07 11:25:33
问题 I have a problem with link_to to send variable. With form_for and submit button works fine, but I need send the data with link_to. This works fine with form_for: <%= form_for (@post), :method => :post, :remote => true, :html => { :id => "#{@post.id}" }, :url => { :controller => "posts", :action => "follow", :post_id => post.id } do |f| %> <%= f.submit "Follow" %> <% end %> This not works :(: <%= link_to post_path(@post), :method => :post, :remote => true, :html => { :id => "#{@post.id}" },

PHP - session_set_cookie_params(), lifetime doesn't work

不想你离开。 提交于 2019-12-07 03:53:25
As first, I know a lot questions are like mine, but I really don't know what I'm doing wrong... As you might've guessed, I've a PHP script involving sessions. Everything works like a charm, except setting the lifetime of my session. I want to keep the session active for two weeks, but instead my (Chrome) browser says it's set to xpire after the browsing session (and it does). My PHP script: session_name('DSWLogin'); // Naming the session session_set_cookie_params(2*7*24*60*60); // Making the cookie live for 2 weeks session_start(); // Starting the session It really doesn't work. Thanks in

C# method overload with params and optionals

不问归期 提交于 2019-12-07 03:46:31
问题 Today I discovered something strange. I wonder why this works: static void Main(string[] args) { Console.WriteLine(ExampleMethod(3)); Console.ReadKey(); } public static string ExampleMethod(int required, params int[] optionalint) { return "ExampleMethod 2"; } public static string ExampleMethod(int required, string optionalstr = "default string", int optionalint = 10) { return "ExampleMethod 1"; } Think about it: What is the result when you call ExampleMethod(3); In my opinion it leads to an

Providing multiple When statements for SpecFlow Scenario

风格不统一 提交于 2019-12-07 00:46:56
问题 Fairly new to SpecFlow so bear with me. I was working with a colleague to get a basic understanding of what you can do with SpecFlow. We were using the classic FizzBuzz problem, which we have used to test unit testing to compare how we would do a similar problem in SpecFlow. we wrote our scenarios as follows growing the code as needed: (please excuse naming just wanted to get the tests writ) Scenario: 1 is 1 Given there is a FizzBuzzFactory When you ask What I Am with the value of 1 Then the