Search Results

Search found 15797 results on 632 pages for 'session variables'.

Page 90/632 | < Previous Page | 86 87 88 89 90 91 92 93 94 95 96 97  | Next Page >

  • Ruby on Rails when create method fails, render loses local variables

    - by Jimmy
    Hey guys I have a simple create method with some validations and whenever the create method fails due to validation errors it re-renders the 'new' action. The problem is in my new action/view I have a local variable that is established in the action and passed to a partial to render some related information to what the user is creating. Now when my create action fails and I try to re-render the 'new' action I'm getting the always awesome undefined method `cover' for nil:NilClass error. What is the best way to handle re-establishing my action's local variables on a render instead of redirecting to the action again and the user losing the data they input?

    Read the article

  • C static variables and intialization

    - by yCalleecharan
    Hi, If I have a global static variable x like in this code #include <stdio.h> #include <stdio.h> static int x; int main(void) { DO SOMETHING WITH x HERE x++; } What will be difference if I opted to initialize x to a value first say as in static int x = 0; before entering "main"? In my first case where I didn't assign a value to x, does the compiler implicitly know that x is to be set to zero as it's a static variable? I heard that we can do this with static variables. Thanks a lot...

    Read the article

  • Objects instead of global variables in Perl

    - by Gaurav Dadhania
    I don't know if this is the right thing to do. But I'm lookig for tutorials/articles on using objects instead of global variables to store state. For eg. package something # some code here... # that generates errors and uses # something::errors to track errors. package something::errors sub new { my ($this) = @_; bless $this; return $this; } sub setErrors{ my ($this, @errors) = @_; $this->{errors} = \@errors; } sub getErrors{ my ($this) = @_; return $this->{errors}; } Is this better than using global varibles? Any down-sides to this? Any approach which might be better? Thanks.

    Read the article

  • Mod_Rewrite: Insert "/" between variables and values in URL

    - by Abs
    Hello all, I am attempting clean useful URLs using mod_rewrite. I am sure this is a common question but I am not so hot with mod_rewrite: I have this URL: http://mysite.com/user.php?user=fatcatmat&sort=popularv I want to be able to rewrite it like this: http://mysite.com/user/user/fatcatmat/sort/popularv (Is there a way to remove duplicates in a URL?) I think I have managed to do the removal of the PHP extension. RewriteRule ^(.*)\$ $1.php [nc] Is the above correct? For the separate pages, I would have something like this. RewriteRule ^/?user(/)?$ user.php Main Question: Its a bit tedious to do all the above but is there a MEGA rewrite rule that will just place "/" in between variables and their values and remove the .php extension from all pages? Thank you for any help.

    Read the article

  • using subset but old variables still left

    - by user2520852
    I am working with a data set, which is basically daily usage data (let's just say variable X and Y) by different cities (about 150 cities). I have created a subset of data for only specific cities, choosing just 3 of the 150 cities. Then when I do tapply by cities, I get means for 3 cities but also get NA for all other 147 cities that was in the data set. I am using the below coding df<-read.csv(...) df_sub<-subset(df,df$City==1|df$City==3|df$City==19) X_Breakdown<-tapply(X,df_sub$City, mean, na.rm=TRUE) Print(X_Breakdown) City 1 City 2 15 NA City 3 City 4 12 NA City 5 City 6 NA NA Hope you get the idea. I would like to get a dataset that only contains the 3 cities that I'm interested in. It seems that the set of variables is encoded in R, is there a way to fix this? Kindly advise. Thanks

    Read the article

  • Using variables for colors in table cells

    - by Mark Robinson
    Using the variables extension, I want to change the background color of a cell in a table. So far I've done this: {{#vardefine:green|<span style="background:Green; color:White">text</span>}} The problem is that, when I add {{#var:green}} to the cell, only the text itself has a green background. Ideally, I want the whole cell to have a background color, like it does if I use this: | bgcolor="#ff00ff" | test or this | style="background:silver" |silver in the cell. Does anyone know how to solve this?

    Read the article

  • How to warn for the use of unset variables in a korn shell script

    - by Lepu
    Is there any way to throw errors or warnings in a korn shell script to prevent the use of unset variables ? Let's assume I have a temporary folder that I want to remove. TEMP_FILES_DIR='/app/myapp/tmp' rm -Rf $TEMP_FILE_DIR #notice the misspelling How to prevent this kind of mistakes before they actually happen? I know the script should check for file existence and empty string before attempting to remove, this is just a silly example to illustrate a mistake that could have been avoided with some warnings. I don't know if this feature exists in ksh. If it does exist, how do you turn it on?

    Read the article

  • Java Passing variables around classes

    - by nazerb
    I am new to java and am trying to pass variables like in the following example from one class to another, im wondering is this possible and how i would go about it if it is. As this code does not work as it is not static. Main Class public class testAll { public static void main(String[] args) { One one = new One(); Two two = new Two(); } } The first class: public class One { public int test = 4; public int getTest() { return this.test; } } The second class: public class Two { public void value() { System.out.print("Var is: " + One.getTest()); } } Thanks, Naz

    Read the article

  • Setting Environment Variables For NMAKE Before Building A 'Makefile Solution'

    - by John Dibling
    I have an MSVC Makefile Project in which I need to set an environment variable before running NMAKE. For x64 builds I needs to set it to one value, and for x86 builds I need to set it to something else. So for example, when doing a build I would want to SET PLATFORM=win64 if I'm building a 64-bit compile, or SET PLATFORM=win32 if I'm building 32-bit. There does not appear to be an option to set environment variables or add a pre-build even for makefile projects. How do I do this? EDIT: Running MSVC 2008

    Read the article

  • jQuery variables and scope

    - by Peuge
    I am writing a jQuery plugin and am running into a few problems with regard to variables. For example I have the following skeleton structure for my plugin, which is going to act on a textbox. In my init function I want to set a variable and bind a keypress event to my textbox. That keypress event needs to call another function, in which I need the variable. Is this possible? (function($){ var methods = { init : function(options){ return this.each(function(){ var $this = $(this); var someVar = 'somevar'; $this.keypress(function(event){ //I want to call my customFunction }); }); }, customFunction : function(){ //I am wanting to access 'someVar' here }; $.fn.mynamespace = function(method){ //handle which method to call here }; })(jQuery); Many thanks in advance.

    Read the article

  • need to extract certain values from attribute and place them in variables

    - by user357034
    In the following markup on a page I want to extract out the following and put them in seperate variables. 1- In the onclick attribute get the value after the "ProductID" and put it in its own variable. "ProductID" So in this case it would be 318 2- In the onclick attribute get the value after the "Orig_price" and put it in a variable, "Orig_Price" So in this case it would be 22.95 3- In the onclick attribute get the value after the "width" and put it in a variable, "width" So in this case it would be 330 4- In the onclick attribute get the value after the "height" and put it in a variable, "height" So in this case it would be 300 <a href="javascript:void(0);" onclick="window.open('/BulkDiscounts.asp?ProductID=318&ProductCode=' + escape('LB30X40ES') + '&Orig_Price=22.95', 'Discounts', 'scrollbars,status,resizable,width=330,height=300');"><img src="/v/vspfiles/templates/100/images/buttons/btn_quantitydiscounts.gif" border="0" align="absmiddle"></a>

    Read the article

  • Using Django view variables inside templates

    - by William
    Hi, this is a rather basic question (I'm new to Django) but I'm having trouble using a variable set in my view inside my template. If I initialize a string or list inside my view (i.e. h = "hello") and then attempt to call it inside a template: {{ h }} there is neither output nor errors. Similarly, if I try to use a variable inside my template that doesn't exist: {{ asdfdsadf }} there is again no error reported. Is this normal? And how can I use my variables within my templates. Thanks!

    Read the article

  • How do I scope variables properly in jQuery?

    - by safetycopy
    I'm working on a jQuery plugin, but am having some trouble getting my variables properly scoped. Here's an example from my code: (function($) { $.fn.ksana = function(userOptions) { var o = $.extend({}, $.fn.ksana.defaultOptions, userOptions); return this.each(function() { alert(rotate()); // o is not defined }); }; function rotate() { return Math.round(o.negRot + (Math.random() * (o.posRot - o.negRot))); }; $.fn.ksana.defaultOptions = { negRot: -20, posRot: 20 }; })(jQuery); I'm trying to get the private function rotate to be able to see the o variable, but it just keeps alerting 'o is not defined'. I'm not sure what I'm doing wrong.

    Read the article

  • jQuery hide/show div using variables

    - by user295927
    I am a nOOb to jQuery. I want to use variables in jQuery to hide/show divs. what I have so far is: $(document).ready(function(){ $('#listMenu a').click(function () { var getPage = $(this).attr("id"); var getName = $(this).attr("name"); //console.log(getPage); //console.log(getName); $("#" & getName ).show(); }); }); firebug console shows that I have the vars correctly, but I get this error next: this[H].style is undefined [Break on this error] (function(){var R=/((?:((?:([^()]+)...typeof K==="string"?K:K+"px")}})})(); any help is appreciated. sjs

    Read the article

  • Annotations: methods vs variables

    - by Zenzen
    I was always sure (don't know why) that it's better to add annotations to variables, but while browsing the Hibernate doc http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#entity-hibspec-collection I noticed they tend to annotate the methods. So should I put my annotations before methods, like this: @Entity public class Flight implements Serializable { private long id; @Id @GeneratedValue public long getId() { return id; } public void setId(long id) { this.id = id; } } Or is it better to do it like this: @Entity public class Flight implements Serializable { @Id @GeneratedValue private long id; public long getId() { return id; } public void setId(long id) { this.id = id; } } Or maybe there's no difference?

    Read the article

  • Manage build target variables in iphone project

    - by DougW
    We're transitioning to an automated build process for our iphone projects. These projects can be checked out by individual devs, in which case all the API URLs need to point to a certain path. There are also a variety of build environments, each with their own API root paths. I could probably add multiple, different build targets, and have each of them include a different URLs definition file, but this seems like a lot of upkeep and a bit overkill. Any best practices out there for swapping a few environmental variables for different build environments without much fuss?

    Read the article

  • ggplot add percentage labels based on x-axis variables

    - by eugeneyan
    I've a ggplot that shows the counts of tweets for some brands as well as a label for the overall percentage. This was done with much help from this link: ggplot: showing % instead of counts in charts of categorical variables # plot ggplot of brands ggplot(data = test, aes(x = brand, fill = brand)) + geom_bar() + stat_bin(aes(label = sprintf("%.02f %%", ..count../sum(..count..)*100)), geom = 'text', vjust = -0.3) Next, I would like to plot it based on brand and sentiment, with the labels for the bars of each brand totalling up to 100%. However, I have difficulty amending my code to do this. Would you be able to help please? Also, would it be possible to change the colours for neu to blue and pos to green? # plot ggplot of brands and sentiment ggplot(data = test, aes(x = brand, fill = factor(sentiment))) + geom_bar(position = 'dodge') + stat_bin(aes(label = sprintf("%.02f %%", ..count../sum(..count..)*100)), geom = 'text', position = position_dodge(width = 0.9), vjust=-0.3)

    Read the article

  • Does writing program using global variables is safer?

    - by ZoZo123
    I was reading about buffer, stack and heap overflows. I read this post as well. my question is like that: if I use only global variables in my code, can I say it prevents all the exploits of overflow? let's say I have this buffers in code declared in the global scope: char buf1[10]; char buf2[100]; If I send buf1 as the buffer to recv(int s, char *buf, int len,int flags); I will overwrite the data segment and may ruin the buf2 content, right? Would I be able to run a code from it because as I know it is not a code segment and data segment is not executable. Can we conclude that using Globals is the safest way?

    Read the article

  • What environment variables available while starting the script using init.d boot process

    - by raj_arni
    My problem is like this (OS is Sun Solaris): 1) At the boot time I want to start a process using a specific script. I am doing this by putting this script in /etc/init.d (and following other K and S rules) 2) The program which will be called by the script is located at $HOME/xxx/yyy location. 4) I am using 'su - {myuser} -c "{full path of the program}"' in order to execute the script as {myuser} 3) I dont want to hardcode the value of $HOME in the script but want to use the $HOME env variable only. How can I get this $HOME env variable in the shell script? Also what other variables will be available to me?

    Read the article

  • Using function arguments as local variables

    - by Rubys
    Something like this (yes, this doesn't deal with some edge cases - that's not the point): int CountDigits(int num) { int count = 1; while (num >= 10) { count++; num /= 10; } return count; } What's your opinion about this? That is, using function arguments as local variables. Both are placed on the stack, and pretty much identical performance wise, I'm wondering about the best-practices aspects of this. I feel like an idiot when I add an additional and quite redundant line to that function consisting of int numCopy = num, however it does bug me. What do you think? Should this be avoided?

    Read the article

  • Javascript : random number between variables issue

    - by Mayhem
    I've seen the other examples on this site but I just can't get it to work. I'm trying to generate a random number between 2 user input variables on a form. The numbers will always be positive numbers. min = document.getElementById('min').value; max = document.getElementById('max').value; waitTimer = Math.floor(Math.random() * (max - min + 1)) + min; When min = 5 / max = 10, waitTimer is sometimes returning results like 2, 4 and 28 and so on. What am I doing wrong?

    Read the article

  • Class works without declaring variables?

    - by Maxim Droy
    I'm learned php as functional and procedure language. Right now try to start learn objective-oriented and got an important question. I have code: class car { function set_car($model) { $this->model = $model; } function check_model() { if($this->model == "Mercedes") echo "Good car"; } } $mycar = new car; $mycar->set_car("Mercedes"); echo $mycar->check_model(); Why it does work without declaration of $model? var $model; in the begin? Because in php works "auto-declaration" for any variables? I'm stuck

    Read the article

  • Class member variables, methods and their state

    - by codeMonkey
    How should class member variables be used in combination with class methods? Let's say I have a class 'C' with a member variable 'someData'. I call C.getData(), which does not return a value but instead puts data in C.someData. The class that instantiated 'C' first calls C.getData and then uses the data by accessing the member variable C.someData. I call C.getData() in the class that instantiated 'C' which is a function that returns data. I myself prefer the second way. But it also depends on the situation and it's a small difference. Is it 'bad' to have class methods that depend on the classes internal state? What are the best conventions?

    Read the article

  • Actual SQL statement after bind variables specified

    - by bioffe
    I am trying to log every SQL statement executed from my scripts. However I contemplate one problem I can not overcome. Is there a way to compute actual SQL statement after bind variables were specified. In SQLite I had to compute the statement to be executed manually, using code below: def __sql_to_str__(self, value,args): for p in args: if type(p) is IntType or p is None: value = value.replace("?", str(p) ,1) else: value = value.replace("?",'\'' + p + '\'',1) return value It seems CX_Oracle has cursor.parse() facilities. But I can't figure out how to trick CX_Oracle to compute my query before its execution.

    Read the article

  • passing variables when calling methon in new thread (iphone)

    - by Mouhamad Lamaa
    dear stacks i need to pass variables to the thread method when creating a new thread my code is the follwing //generating thread [NSThread detachNewThreadSelector:@selector(startThread) toTarget:self withObject:nil]; thread job - (void)startThread:(NSInteger *)var img:(UIImageView *) Img{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [NSThread sleepForTimeInterval:var]; [self performSelectorOnMainThread:@selector(threadMethod) withObject:nil waitUntilDone:NO]; //i need to pass Img to threadMethod: [pool release]; } thread Method - (void)threadMethod:(UIImageView *) Img { //do some coding. } so how i can do this (pass parameter to both of methods

    Read the article

< Previous Page | 86 87 88 89 90 91 92 93 94 95 96 97  | Next Page >