Search Results

Search found 4088 results on 164 pages for 'params keyword'.

Page 58/164 | < Previous Page | 54 55 56 57 58 59 60 61 62 63 64 65  | Next Page >

  • Passing parameters thru Ruby's OAuth

    - by JP
    I'm using Mirven's Twitter OAuth Sinatra example and trying to figure out how I can send a 'next page' parameter with the Oauth request: ie. The user attempts to visit /edit/profile which requires a login so I redirect to /request which deals with login via twitter - I now want to be able to redirect the user to the address they were originally looking for if they log in successfully. I thought I could do this in the .get_request_token line with this code: @request_token = @consumer.get_request_token({:oauth_callback => "http://#{request.host}/auth"},{:next => params['next'] || '/'}) But params has no additional items in the /auth handler. I'm new to OAuth, how would I go about doing this?

    Read the article

  • Using Interfaces in JNI

    - by lhw
    I am trying to use (*env)->RegisterNatives to add methods to a defined class which I then add to a callback list. The callback sender of course expects my class to implement a certain interface which I do not. And is failing on execution. If I add the keyword "implements Listener" to my class in Java the javac expects to have the methods definition in Java or with native keyword which I try to avoid here, as I'd like to register the methods within the JNI_OnLoad and execute one of them afterwards. The question now is: Can I implement the interface in JNI or avoid the error message in Java?

    Read the article

  • Rails 3.0/3.2: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id

    - by Nick5a1
    I'm following the Kevin Skoglund tutorial Ruby on Rails 3 Essential Training, which was written for rails 3.0, though I am currently using 3.2. It uses the following method in the pages_controller with a before_filter to display only the pages which belong to the parent subject. The tutorial explicitly uses .find_by_id because if the result is nil it "will not return an error". However I get the "Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id" error when trying to view a page where @subject has been set to nil. def find_subject if params[:subject_id] @subject = Subject.find_by_id(params[:subject_id]) end end The actual code that is causing the error is: def list @pages = Page.order("pages.position ASC").where(:subject_id => @subject.id) end Is this something that has changed since 3.0? If so, what would be the correct way to implement this functionality in 3.2?

    Read the article

  • XSLT: How to escape square brackets in Urls

    - by ilariac
    I have a set of records from Solr where field[@name='url'] can have the following format: http://url/blabla/blabla.aspx?sv=[keyword%20keyword,%201] My understanding is that the square brackets denote an array syntax and I would like to use XSLT to remove the square brackets from all Urls. The reason for this is that I am using an Open URL resolver, which does not currently handle well those characters. The best option would be to strip the square brackets from all URLs before such resources are mediated by the Open URL resolver. There are cases where I have multiple occurrences of square brackets per Url. Can you please help me with this? Thanks for your help, I.

    Read the article

  • how to use a pear package!?

    - by Naughty.Coder
    I want to use HTTP_DOWNLOAD to manage my downloads ,, I have never used PEAR before !! HTTP_DOWNLOAD depends on many other packages , I downloaded them and the ones they , in turn , depend on and this is the structure I made : Download.PHP <---HTTP_DOWNLOAD MAIN FILE Header.php <--- HTTP_HEADER MAIN FILE PEAR.php PEAR5.php Type.php <--- MIME_Type >Type <---- FOLDER - Extension.php MIME_Type File - Parameter.php MIME_Type File assuming that Http_DOWNLOAD depends on : * PHP 4.2.0 * PEAR 1.4.0b1 * PEAR * HTTP_Header * pcre extension * Archive_Tar (Optional) * Archive_Zip (Optional) * MIME_Type (Optional) * mime_magic extension (Optional) * pgsql extension (Optional) and I edited the paths inside each file to reflect this structure , and I tried to run the following code : <?php require_once 'Download.php'; $params = array('file'=>'file.zip'); $down = new HTTP_Download($params); $down->send(true); ?> nothing happens !! I also got a hard time trying to figure how to use the class and I think this code should work .. but not sure ! Help Please !

    Read the article

  • Problem with Delete Link?

    - by Kevin
    When I click on the delete link I created, it doesn't do anything (even the flash[:notice] part) in the controller. Am I not calling the .delete? part correctly? The POST part works as I can add tips. Link: <%= link_to "Delete", :controller => "/admin", :action => "tips", :id => t.id, :method => :delete, :confirm => "Are you sure?" %> Admin Controller def tips @tips = Tip.all if request.post? tip = Tip.new(params[:geek_tips]) if tip.save flash[:notice] = "Saved!" redirect_to :action => "tips" else flash[:notice] = "Error!" end elsif request.delete? tip = Tip.find_by_id(params[:id]) tip.delete! flash[:notice] = "Delete Message" redirect_to :action => "tips" end end

    Read the article

  • JAXB appending unneeded namespace declarations to tags

    - by jb
    I'm implementing a homebrew subprotocol of XMPP, and i'm using combination of StAX and JAXB for parsing/marshalling mesages. And when I marshall a message I end up with loads of unneded namespace declarations: <ns2:auth xmlns:ns2="urn:ietf:params:xml:ns:ilf-auth" xmlns:ns4="ilf:iq:experiment:power" xmlns:ns3="ilf:iq:experiment:init" xmlns:ns5="ilf:iq:experiment:values" xmlns:ns6="ilf:iq:experiment:result" xmlns:ns7="ilf:iq:experiment:stop" xmlns:ns8="ilf:iq:experiment:end"> compton@ilf</ns2:auth> instead of: <ns:auth xmlns:ns="urn:ietf:params:xml:ns:ilf-auth>compton@ilf</ns:auth> Is there any way to turn that of? All these namespaces are used in different messages that get marshalled/unmarshalled by JAXB, but every message uses one namespace. PS. I am not an XML expert please dont rant me if I did some stupid mistake ;)

    Read the article

  • Rails3. How do I display two different objects in a search?

    - by JZ
    I am using a simple search that displays search results: @adds = Add.search(params[:search]) In addition to the search results I'm trying to utilize a method, nearbys(), which displays objects that are close in proximity to the search result. The following method displays objects which are close to 2, but it does not display object 2. How do I display object 2 in conjunction with the nearby objects? @adds = Add.find(2).nearbys(10) While the above code functions, when I use search, @adds = Add.search(params[:search]).nearbys(10) a no method error is returned, undefined methodnearbys' for Array:0x30c3278` How can I search the model for an object AND use the nearbys() method AND display all results returned?

    Read the article

  • Using an extended interceptor in struts2 does not work w/ action parameters

    - by Ricardo
    I have a default package w/ an interceptor configure, and i'm extending that package into another one and calling the same interceptor <action name="availability**"> <param name="subTab">availability</param> <interceptor-ref name="tabStack"/> <result>/WEB-INF/jsp/index.jsp?include=visibilit/availability.jsp</result> </action> The problem is that the param is not being read inside my interceptor code: Map params = invocation.getInvocationContext().getParameters(); subTab = params.get("subTab").toString(); //NULL exception Any idea how i can pass parameters to extended interceptors? Thanks!

    Read the article

  • C#/ASP.NET MVC 4 Instantiate Object Derived From Interface In Factory Method

    - by Chris
    Currently have a Factory class that features a GetSelector function, which returns a concrete implementation of ISelector. I have several different classes that implement ISelector and based on a setting I would like to receive the appropriate ISelector back. public interface ISelector { string GetValue(string Params); } public class XmlSelector : ISelector { public string GetValue(string Params) { // open XML file and get value } } public static class SelectorFactory { public static ISelector GetSelector() { return new XmlSelector(); // Needs changing to look at settings } } My question is what is the best way to store the setting? I am aware of using AppSettings etc. but I'm not sure whether I want to have to store strings in the web.config and perform a switch on it - just seems to be really tightly coupled in that if a new implementation of ISelector is made, then the Factory would need to be changed. Is there any way of perhaps storing an assembly name and instantiating based on that? Thanks, Chris

    Read the article

  • SpineJS and RequireJS

    - by ot3m3m
    I am using require.js 2.0. I have the following code that is called initially by require: app.js requirejs.config({ paths: { app: '..', spine: 'spine_src/spine', cs: "cs", }, shim: { 'spine_src/route': { deps: ['spine'] } } }); // Start the main app logic. requirejs(['cs!app/StartApp_Admin', 'spine','spine_src/route'], function (StartApp_Admin, Spine, Route) { { new StartApp_Admin(); } }); And the following controller: StartApp_Admin define () -> class StartApp_Admin extends Spine.Controller constructor: -> @routes "/twitter/:id": (params) -> console.log("/users/", params.id) Spine.Route.setup() When I execute the application I get the following error in my spine route library file (route.js). The application breaks when I call Spine.Route.setup() Uncaught TypeError: Object function (element) {return element;} has no method 'extend' Any help would be greatly appreciated

    Read the article

  • HttpRequestValidationexception on Asp.Net MVC

    - by elranu
    I’m getting an HttpRequestValidationexception with this error message: “A potentially dangerous Request.Form value was detected from the client”. But I have AllowHtml on the property that I’m getting the error. The problem is that later in my code I’m getting the following property to know in witch format I will show my view ControllerContext.HttpContext.Request.Params.AllKeys.Contains("format"). And on this “Param Getter” I’m getting the error. Let’s say my code is similar to the following: public class House { [AllowHtml] public string Text { get; set; } public string Name { get; set; } } [HttpPost, ValidateAntiForgeryToken] public ActionResult CreateTopic(House h) { //business code if(ControllerContext.HttpContext.Request.Params.AllKeys.Contains("format")) { Return view; } } How can I solve this? I already try with the ValidateInput(false) attribute on the controller action method. Any idea?

    Read the article

  • Windows 7 - pydoc from cmd

    - by Random_Person
    Okay, I'm having one of those moments that makes me question my ability to use a computer. This is not the sort of question I imagined asking as my first SO post, but here goes. Started on Zed's new "Learn Python the Hard Way" since I've been looking to get back into programming after a 10 year hiatus and python was always what I wanted. This book has really spoken to me. That being said, I'm having a serious issue with pydoc from the command. I've got all the directories in c:/python26 in my system path and I can execute pydoc from the command line just fine regardless of pwd - but it accepts no arguments. Doesn't matter what I type, I just get the standard pydoc output telling me the acceptable arguments. Any ideas? For what it's worth, I installed ActivePython as per Zed's suggestion. C:\Users\Chevee>pydoc file pydoc - the Python documentation tool pydoc.py <name> ... Show text documentation on something. <name> may be the name of a Python keyword, topic, function, module, or package, or a dotted reference to a class or function within a module or module in a package. If <name> contains a '\', it is used as the path to a Python source file to document. If name is 'keywords', 'topics', or 'modules', a listing of these things is displayed. pydoc.py -k <keyword> Search for a keyword in the synopsis lines of all available modules. pydoc.py -p <port> Start an HTTP server on the given port on the local machine. pydoc.py -g Pop up a graphical interface for finding and serving documentation. pydoc.py -w <name> ... Write out the HTML documentation for a module to a file in the current directory. If <name> contains a '\', it is treated as a filename; if it names a directory, documentation is written for all the contents. C:\Users\Chevee> EDIT: New information, pydoc works just fine in PowerShell. As a linux user, I have no idea why I'm trying to use cmd anyways--but I'd still love to figure out what's up with pydoc and cmd. EDIT 2: More new information. In cmd... c:\>python c:/python26/lib/pydoc.py file ...works just fine. Everything works just fine with just pydoc in PowerShell without me worrying about pwd, or extensions or paths.

    Read the article

  • Pylons and Facebook

    - by Nayan Jain
    The following is my oauth template top.location.href='https://graph.facebook.com/oauth/authorize?client_id=${config['facebook.appid']}&redirect_uri=${config['facebook.callbackurl']}&display=page&scope=publish_stream'; Click here to authorize this application When I hit the page I am prompted to login (desired), upon login I am redirected in a loop between a permissions page and an app page. My controller looks like: class RootController(BaseController): def __before__(self): tmpl_context.user = None if request.params.has_key('session'): access_token = simplejson.loads(request.params['session'])['access_token'] graph = facebook.GraphAPI(access_token) tmpl_context.user = graph.get_object("me") def index(self): if not tmpl_context.user: return render('/oauth_redirect.mako') return render('/index.mako') I'm guessing my settings are off somewhere, probably with the callback. Not to sure if it is an issue with my code or the python sdk for facebook.

    Read the article

  • Stuck with luasec LUA secure socket

    - by PeterMmm
    This example code fails: require("socket") require("ssl") -- TLS/SSL server parameters local params = { mode = "server", protocol = "sslv23", key = "server.key", certificate = "server.crt", cafile = "server.key", password = "123456", verify = {"peer", "fail_if_no_peer_cert"}, options = {"all", "no_sslv2"}, ciphers = "ALL:!ADH:@STRENGTH", } local socket = require("socket") local server = socket.bind("*", 8888) local client = server:accept() client:settimeout(10) -- TLS/SSL initialization local conn,emsg = ssl.wrap(client, params) print(emsg) conn:dohandshake() -- conn:send("one line\n") conn:close() request https://localhost:8888/ output error loading CA locations ((null)) lua: a.lua:25: attempt to index local 'conn' (a nil value) stack traceback: a.lua:25: in main chunk [C]: ? Not very much info. Any idea how to trace down to the problem ?

    Read the article

  • Jsonp request using jquery to fetch bing web results

    - by Blankman
    using this as a guide: http://msdn.microsoft.com/en-us/library/dd250846.aspx can someone help me with the jquery call? Do I actually pass in the javascript code for the callback, or just the name of the function? BingSearch = function($bingUrl, $bingAppID, $keyword, $callBack) { $bingUrl = $bingUrl + "?JsonType=callback&JsonCallback=" + $callBack + "&Appid=" + $bingAppID + "&query=" + encodeURI($keyword) + "&sources=web"; $.ajax({ dataType: 'jsonp', jsonp: $callBack, url: $bingUrl, success: function(data) { alert('success'); $callBack(data); }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert("error: " + textStatus); } }); };

    Read the article

  • Repeating parallax using Cocos2D on Android

    - by Saurabh Verma
    I want to draw a infinitely repeating parallax using Cocos2D on Android. Now, there are some solutions given to this problem in Objective C, but I'm stuck with my implementation in Android. I have tried using CCSprite background = CCSprite.sprite("background_island.png"); CCTexParams params = new CCTexParams(GL10.GL_LINEAR,GL10.GL_LINEAR,GL10.GL_REPEAT,GL10.GL_REPEAT); background.getTexture().setTexParameters(params); But it only extends the background in 1 direction. I guess I have to use 2 sprites, such that as soon as 1st finishes, the other starts and vice versa, but I'm stuck with the implementation.

    Read the article

  • Problem about python import with error

    - by xiao
    Hello, I have write a small python module with one class and two functions. The skeleton of the module is as following: #file name: test_module.py class TestClass: @classmethod def method1(cls, param1): #to do something pass def __init__(self, param1): #to do something ... def fun1(*params): #to do something ... def fun2(*params): #to do something ... Another py file is a small script which imports function and class from the module, as following: import sys from test_module import TestClass, fun1, fun2 def main(sys_argv): li = range(5) inst1 = TestClass(li) fun1(inst1) fun2(inst1) return if __name__ == "__main__": main(sys.argv) But when I execute the script, it is broken with following message: ./script.py: line 4: syntax error near unexpected token `(' ./script.py: line 4: `def main(sys_argv):' I am not sure what the problem is. Is it a problem with import? But when I try to import the module in ipython, everything is just ok.

    Read the article

  • VB6 ADO Command to SQL Server

    - by Emtucifor
    I'm getting an inexplicable error with an ADO command in VB6 run against a SQL Server 2005 database. Here's some code to demonstrate the problem: Sub ADOCommand() Dim Conn As ADODB.Connection Dim Rs As ADODB.Recordset Dim Cmd As ADODB.Command Dim ErrorAlertID As Long Dim ErrorTime As Date Set Conn = New ADODB.Connection Conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Initial Catalog=database;Data Source=server" Conn.CursorLocation = adUseClient Conn.Open Set Rs = New ADODB.Recordset Rs.CursorType = adOpenStatic Rs.LockType = adLockReadOnly Set Cmd = New ADODB.Command With Cmd .Prepared = False .CommandText = "ErrorAlertCollect" .CommandType = adCmdStoredProc .NamedParameters = True .Parameters.Append .CreateParameter("@ErrorAlertID", adInteger, adParamOutput) .Parameters.Append .CreateParameter("@CreateTime", adDate, adParamOutput) Set .ActiveConnection = Conn Rs.Open Cmd ErrorAlertID = .Parameters("@ErrorAlertID").Value ErrorTime = .Parameters("@CreateTime").Value End With Debug.Print Rs.State ' Shows 0 - Closed Debug.Print Rs.RecordCount ' Of course this fails since the recordset is closed End Sub So this code was working not too long ago but now it's failing on the last line with the error: Run-time error '3704': Operation is not allowed when the object is closed Why is it closed? I just opened it and the SP returns rows. I ran a trace and this is what the ADO library is actually submitting to the server: declare @p1 int set @p1=1 declare @p2 datetime set @p2=''2010-04-22 15:31:07:770'' exec ErrorAlertCollect @ErrorAlertID=@p1 output,@CreateTime=@p2 output select @p1, @p2 Running this as a separate batch from my query editor yields: Msg 102, Level 15, State 1, Line 4 Incorrect syntax near '2010'. Of course there's an error. Look at the double single quotes in there. What the heck could be causing that? I tried using adDBDate and adDBTime as data types for the date parameter, and they give the same results. When I make the parameters adParamInputOutput, then I get this: declare @p1 int set @p1=default declare @p2 datetime set @p2=default exec ErrorAlertCollect @ErrorAlertID=@p1 output,@CreateTime=@p2 output select @p1, @p2 Running that as a separate batch yields: Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'default'. Msg 156, Level 15, State 1, Line 4 Incorrect syntax near the keyword 'default'. What the heck? SQL Server doesn't support this kind of syntax. You can only use the DEFAULT keyword in the actual SP execution statement. I should note that removing the extra single quotes from the above statement makes the SP run fine. ... Oh my. I just figured it out. I guess it's worth posting anyway.

    Read the article

  • Loading jar file using JCL(JarClassLoader ) : classpath in manifest is ignored ..

    - by Xinus
    I am trying to load jar file using JCL using following code FileInputStream fis = new FileInputStream(new File( "C:\\Users\\sunils\\glassfish-tests\\working\\test.jar") ); JarClassLoader jc = new JarClassLoader( ); jc.add(fis); Class main = jc.loadClass( "highmark.test.Main" ); String[] str={}; main.getMethod("test").invoke(null);//.getDeclaredMethod("main",String[].class).invoke(null,str); fis.close(); But when I try to run this program I get Exception as Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at Main.main(Main.java:21) Caused by: java.lang.RuntimeException: Embedded startup not found, classpath is probably incomplete at org.glassfish.api.embedded.Server.<init>(Server.java:292) at org.glassfish.api.embedded.Server.<init>(Server.java:75) at org.glassfish.api.embedded.Server$Builder.build(Server.java:185) at org.glassfish.api.embedded.Server$Builder.build(Server.java:167) at highmark.test.Main.test(Main.java:33) ... 5 more According to this it is not able to locate class, But when I run the jar file explicitly it runs fine. It seems like JCL is ignoring other classes present in the jar file, MANIFEST.MF file in jar file shows: Manifest-Version: 1.0 Class-Path: . Main-Class: highmark.test.Main It seems to be ignoring Class-Path: . , This jar file runs fine when I run it using Java explicitly, This is just a test, in reality this jar file is coming as a InputStream and it cannot be stored in filesystem, How can I overcome this problem , Is there any workaround ? Thanks for any help . UNDATE: Here is a jar Main class : package highmark.test; import org.glassfish.api.embedded.*; import java.io.*; import org.glassfish.api.deployment.*; import com.sun.enterprise.universal.io.FileUtils; public class Main { public static void main(String[] args) throws IOException, LifecycleException, ClassNotFoundException { test(); } public static void test() throws IOException, LifecycleException, ClassNotFoundException{ Server.Builder builder = new Server.Builder("test"); Server server = builder.build(); server.createPort(8080); ContainerBuilder containerBuilder = server.createConfig(ContainerBuilder.Type.web); server.addContainer(containerBuilder); server.start(); File war=new File("C:\\Users\\sunils\\maventests\\simple-webapp\\target\\simple-webapp.war");//(File) inputStream.readObject(); EmbeddedDeployer deployer = server.getDeployer(); DeployCommandParameters params = new DeployCommandParameters(); params.contextroot = "simple"; deployer.deploy(war, params); } }

    Read the article

  • C#: Efficiently search a large string for occurences of other strings

    - by Jon
    Hi, I'm using C# to continuously search for multiple string "keywords" within large strings, which are = 4kb. This code is constantly looping, and sleeps aren't cutting down CPU usage enough while maintaining a reasonable speed. The bog-down is the keyword matching method. I've found a few possibilities, and all of them give similar efficiency. 1) http://tomasp.net/articles/ahocorasick.aspx -I do not have enough keywords for this to be the most efficient algorithm. 2) Regex. Using an instance level, compiled regex. -Provides more functionality than I require, and not quite enough efficiency. 3) String.IndexOf. -I would need to do a "smart" version of this for it provide enough efficiency. Looping through each keyword and calling IndexOf doesn't cut it. Does anyone know of any algorithms or methods that I can use to attain my goal?

    Read the article

  • php and asp problem in uploading

    - by moustafa
    i have an ASP web services to change byte array that given from the client and change it to a file and save it in the web server the code is like this : [WebMethod] public string UploadFile(byte[] f, string fileName) { try { MemoryStream ms = new MemoryStream(f); String path="/myfile/"; String location=HttpContext.Current.Server.MapPath(path); FileStream fs = new FileStream(HttpContext.Current.Server.MapPath(path)+fileName, FileMode.Create); ms.WriteTo(fs); ms.Close(); fs.Close(); return "OK"; } catch (Exception ex) { return ex.Message.ToString(); } } the web services need byte array and file name.. i build the client in php upload.php the code is <html> <body> <form action="action1.php" method="post" enctype="multipart/form-data"> Pilih File Anda: <input type="file" name="myfile" /> <input type="submit" value="Upload" /> </form> </body> <html> and action1.php the code is: <?php require_once('nusoap.php'); $client = new nusoap_client('http://192.168.254.160/testuploadah/FileUploader.asmx?WSDL', 'wsdl','','', '', ''); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } if(is_uploaded_file($_FILES['myfile']['tmp_name'])){ $uploadFile = $_FILES['myfile']; ////how can read byte array of $uploadFile so i can send to web services??? ////are php only can send array or string ? $params[]->f=??????????????? $params[]->fileName=$_FILES['myfile']['name']; $result = $client->call('UploadFile', $params,'', '', false, true); if ($client->fault) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } else { //Check for errors $err = $client->getError(); if ($err) { //// Display the error echo '<h2>Error</h2><pre>' . $err . '</pre>'; } else { //// Display the result echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>'; } } } ?> how can i Send the byte array parameter to the web services,so the web services can started???? i still can resolve this problem,the web services always return an error because i can't send byte array

    Read the article

  • posting twitter status whilst receiving tweets iphone mgtwitterengine

    - by d4ndym1k3
    i have set up a twitter client on my iphone using mgtwitterengine. i've managed to set it up so i can tweet and recieve status updates. using the standard set up you can only receive between 10&20 updates. to be able to receive more updates then that you have to put[_engine getFollowedTimelineSinceID:0 startingAtPage:0 count:50]; but this does not allow you to get more than the original amount untill you activateif (params) { fullPath = [self _queryStringWithBase:fullPath parameters:params prefixed:YES]; } in SA_OAuthTwitterEngine.m. my problem is when i do this i can no longer post a new status from my app. i can have upto 200 statuses in the stream but no posting capabilities. this is the error:Error Domain=HTTP Code=401 "The operation couldn’t be completed. (HTTP error 401.)" any help would be appreciated. many thanks in advance

    Read the article

  • Rails: common approach for handling exceptions in restful actions on objects that have been destroye

    - by Greg
    It is very common in Rails for an objects_controller controller to have RESTful edit and destroy actions like so: def edit @object = Object.find(params[:id]) end def destroy @object = Object.find(params[:id]) @object.destroy redirect_to :back end With an associated view that provides edit and destroy links like so: <%= link_to "Edit the Object", edit_object_path(object) %> <%= link_to "Delete", object, :confirm => 'Are you sure?', :method => :delete %> And it is easy to blow this up. If I open two browser windows, A and B, destroy an object with the "Delete" link in browser A and then press the "Edit" link in browser B, the find() in the edit action throws an exception. Obviously there are several ways to deal with this in the edit action: catch the exception and recover gracefully use @object = find(:first, "conditions... etc. and test the @object before going further But seeing as this is such a common pattern, I would love to know how other folks deal with this situation.

    Read the article

  • combining dynamic text with regular expressions in php

    - by pfunc
    I am experimenting with finding popular keywords using curl, php and regular expressions. I have an array of non-specific nouns that I am matching my keyword search up. So I am looking for words like "the", "and", "that" etc. and taking them out of the keyword search. so I have an array of words like so: $wordArr = [the, and, at,....]; and then running something like: && preg_match('(\bmyword\w*\b)', $key) == false how do I combine these two so it loops through the array finding out if any of the words in the array match the regular expression? I guess I could just do a for loop, but though maybe I could use in_array($wordArr, $key).. or something like that.

    Read the article

< Previous Page | 54 55 56 57 58 59 60 61 62 63 64 65  | Next Page >