params

access params hash in controller

瘦欲@ 提交于 2019-12-01 10:09:34
问题 I have a link <%= link_to 'Add link', new_link_path(:link => {:item1_id => @item.id}) %> passing to def new @link = Link.new(params[:link]) @items = Item.all form is <%= form_for(@link) do |f| %> <%= f.hidden_field :item1_id %> <%= f.collection_select :item2_id , Item.all , :id , :name %> So I want to access like the image linked to the item1_id item. How do I access it? i tried @item1 = Item.find_by_id(params[:link]) and @item1 = Item.find_by_id(params[:item_id]) but I don't know what is

Execute an shell program with node.js and pass params [closed]

倖福魔咒の 提交于 2019-12-01 07:37:38
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . I would like to execute an shell program who require any params with Node.js How can I do that ? 回答1: From: http://www.dzone.com/snippets/execute-unix-command-nodejs To execute shell commands: var sys = require('sys') var exec = require('child_process').exec; exec('command',

Insert cakephp POST params into URL

假如想象 提交于 2019-12-01 01:51:53
I have this form below which contains two checkboxes to sort some products: <form id="FiltreExtraForm" action="" method="post" name="FiltreExtraForm"> <input id="ProductsDeliveryPrice" type="checkbox" value="1" name="data[Products][delivery_price]"/> <input id="ProductsPicture" type="checkbox" value="1" name="data[Products][picture]"/> </form> After POST I do the filtering but I also want to add received parameters to URL E.g: /products/index/delivery_price:1/picture:0 . Is this possible. How can I do that? Note: I don't want to use GET to send form info. deizel Sounds like you are looking to

C# - Is it possible to have null params?

风格不统一 提交于 2019-11-30 16:46:39
public void Foo(params string[] values) { } Is it possible that values can ever be null , or will it always be set with 0 or more items? Absolutely - you can call it with an argument of type string[] with a value of null: string[] array = null; Foo(array); I decided to write some code up to test this for myself. Using the following program: using System; namespace TestParams { class Program { static void TestParamsStrings(params string[] strings) { if(strings == null) { Console.WriteLine("strings is null."); } else { Console.WriteLine("strings is not null."); } } static void TestParamsInts

android set listview height dynamically

雨燕双飞 提交于 2019-11-30 15:59:04
问题 i have ExpandableListview inside ScrollView and i know that's not good but i had too, the only solution to show the whole list is by set its height by code using layoutParams RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, ListViewData.length()); this solution is good but i can't figure the right height that i should give in the Params , SO is there a way to know the actual size from the size of the array Edit: i came up with a solution that

android set listview height dynamically

£可爱£侵袭症+ 提交于 2019-11-30 15:07:45
i have ExpandableListview inside ScrollView and i know that's not good but i had too, the only solution to show the whole list is by set its height by code using layoutParams RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, ListViewData.length()); this solution is good but i can't figure the right height that i should give in the Params , SO is there a way to know the actual size from the size of the array Edit: i came up with a solution that everytime i expand a group of the list am gonna change the height to fit with new geight try this, Use

Variable parameters in C# Lambda

蹲街弑〆低调 提交于 2019-11-30 11:56:11
Is it possible to have a C# lambda/delegate that can take a variable number of parameters that can be invoked with a Dynamic-invoke? All my attempts to use the 'params' keyword in this context have failed. UPDATE WITH WORKING CODE FROM ANSWER : delegate void Foo(params string[] strings); static void Main(string[] args) { Foo x = strings => { foreach(string s in strings) Console.WriteLine(s); }; //Added to make it clear how this eventually is used :) Delegate d = x; d.DynamicInvoke(new[]{new string[]{"1", "2", "3"}}); } The reason that it doesn't work when passing the arguments directly to

Groovy: isn't there a stringToMap out of the box?

不打扰是莪最后的温柔 提交于 2019-11-30 08:03:40
as a tcl developer starting with groovy, I am a little bit surprised about the list and map support in groovy. Maybe I am missing something here. I am used to convert between strings, lists and arrays/maps in tcl on the fly. In tcl, something like "['a':2,'b':4]".each {key, value -> println key + " " + value} would be possible, where as in groovy, the each command steps through each character of the string. This would be much of a problem is I could easily use something like the split or tokenize command, but because a serialized list or map isn't just "a:2,b:4", it is a little bit harder to

Changing the params modifier in a method override

耗尽温柔 提交于 2019-11-30 06:50:55
I'm aware that a params modifier (which turns in one parameter of array type into a so-called "parameter array") is specifically not a part of the method signature. Now consider this example: class Giraffid { public virtual void Eat(int[] leaves) { Console.WriteLine("G"); } } class Okapi : Giraffid { public override void Eat(params int[] leaves) { Console.WriteLine("O"); } } This compiles with no warnings. Then saying: var okapi = new Okapi(); okapi.Eat(2, 4, 6); // will not compile! gives an error( No overload for method 'Eat' takes 3 arguments ). Now, I know that the compiler translates the

params overload apparent ambiguity - still compiles and works?

梦想与她 提交于 2019-11-30 06:34:32
We just found these in our code: public static class ObjectContextExtensions { public static T Find<T>(this ObjectSet<T> set, int id, params Expression<Func<T, object>>[] includes) where T : class { ... } public static T Find<T>(this ObjectSet<T> set, int id, params string[] includes) where T : class { ... } } As you can see, these have the same signature except for the params . And they're being used in several ways, one of them: DBContext.Users.Find(userid.Value); //userid being an int? (Nullable<int>) which, strangely enough to me, resolves to the first overload. Q1: Why doesn't this