Search Results

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

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

  • Rails 3, changing a specific value in a row

    - by Elliot
    Hey Guys, This question seems ridiculously easy, but I seem to be stuck. Lets say we have a table "Books" Each Book, has a name, description, and a status. Lets say I want to create link in the show view, that when clicked, solely changes the status (to "read") for example. So far, I've tried adding a block in the controller, that says: def read @book = Book.find(params[:id]) @book.status = "Read" @book.update_attributes(params[:book]) respond_to do |format| format.html { redirect_to :back} format.xml { render :xml => @book } end end Then I've added a link to the view that is like: <%= link_to "Read", read_book_path(@book), :method = :put % This isn't working at all. I have added it to my routes, but it doesn't seem to matter. Any help would be great! Thanks! -Elliot EDIT: Forgot to add I'm getting a NoMethodError: undefined method `read_book_path'

    Read the article

  • Is it possible to filter by conditions before paginating?

    - by Brian Roisentul
    I'm using ruby on rails 2.3.8 and will_paginate plugin. I've just noticed that if I write something like this: Announcement.paginate :page => params[:page], :per_page => 10, :conditions => some_condition it will work. But, if I write something like this: announcements = Announcement.all :conditions => some_condition @ann = announcements.paginate :page => params[:page], :per_page => 10 it won't recognize conditions. Maybe you're wondering "why would he want to do that?", well, it's a long story and I really need to first filter the conditions and then paginate the results.

    Read the article

  • Using Static methods or none static methods in Dao Class ?

    - by dankyy1
    Hi I generate Dao classes for some DB operations in this manner making methods of Dao class as static or none static is better? Using sample dao class below ,If more than one client got to use the AddSampleItem method in same time?how this may result? public class SampleDao { static DataAcessor dataAcessor public static void AddSampleItem(object[] params) { dataAcessor =new DataAcessor(); //generate query here string query="..." dataAcessor.ExecuteQery(query); dataAcessor.Close(); } public static void UpdateSampleItem(object[] params) { dataAcessor =new DataAcessor(); //generate query here string query="..." dataAcessor.ExecuteQery(query); dataAcessor.Close(); } }

    Read the article

  • Scala isn't allowing me to execute a batch file whose path contains spaces.Same Java code does.What

    - by Geo
    Here's the code I have: var commandsBuffer = List[String]() commandsBuffer ::= "cmd.exe" commandsBuffer ::= "/c" commandsBuffer ::= '"'+vcVarsAll.getAbsolutePath+'"' commandsBuffer ::= "&&" otherCommands.foreach(c => commandsBuffer ::= c) val asArray = commandsBuffer.reverse.toArray val processOutput = processutils.Proc.executeCommand(asArray,true) return processOutput otherCommands is an Array[String], containing the following elements: vcbuild /rebuild path to a .sln file vcVarsAll contains the path to Visual Studio's vcvarsall.bat. It's path is C:\tools\microsoft visual studio 2005\vc\vcvarsall.bat. The error I receive is: 'c:\Tools\Microsoft' is not recognized as an internal or external command, operable program or batch file.. The processutils.Proc.executeCommand has the following implementation: def executeCommand(params:Array[String],display:Boolean):(String,String) = { val process = java.lang.Runtime.getRuntime.exec(params) val outStream = process.getInputStream val errStream = process.getErrorStream ... } The same code, executed from Java/Groovy works. What am I doing wrong?

    Read the article

  • Including Applet in JSP page

    - by Hara Chaitanya
    Hi everyone, I wrote an Applet program which draws a pie chart. The values for the applet should be passed from JSP page. I wrote the following lines of code in JSP jsp:plugin type="applet" code="drawPie" codebase="." width="750" heigth="300" jsp:params jsp:param name="user_id" value="<% =user %" /jsp:params /jsp:plugin and in applet i used String user=getParameter("user_id"); when i open the jsp page nothing comes neither error nor the chart ........ What is the problem/error in the above code snippet.....

    Read the article

  • Jing + swfobject 2.2 = big video in small popup

    - by consultutah
    I am trying to use swfobject 2.2 to display an swf, but the swf won't scale to fit the div that I'm putting it in. You can see what I've got here by clicking on the "Take the product tour" button. Here is the code to generate both the impromptu popup and the sfobject: $.prompt("<div id='flashContent'>Please wait...</div>", { prefix: "tour", top: "2%", buttons: {} }); var flashvars = { scale: "showAll" }; var params = { scale: "showAll"}; var attributes = {}; swfobject.embedSWF("/content/tour.swf", "flashContent", "800", "600", "9.0.0", "expressInstall.swf", flashvars, params, attributes); If, after the flash loads, I right-click and select "Show All", it appears correct. Any ideas on what I am doing wrong? I've verified that it doesn't matter whether I'm using impromptu or not. Thank you,

    Read the article

  • form_tag for search model

    - by kip
    I have a search controller which is to be used to search over a separate model called house. The house model has a restful setup. I want the results listed on the index action of the search controller. The form_tag url is giving me some problems. What is the correct path for this? Below is the search form (search/form): <% form_tag index_search do -%> <p> <%= collection_select(:house, :category_id, Category.all, :id, :name) %> </p> <p> <strong>price</strong><br /> <%= text_field_tag :min_price, params[:min_price], :size => 3 %> <%= text_field_tag :max_price, params[:max_price], :size => 4 %>

    Read the article

  • How to mock/stub calls to message taglib in Grails controller

    - by Dave
    I've got a Grails controller which relies on the message taglib to resolve an i18n message: class TokenController { def passwordReset = { def token = DatedToken.findById(params.id); if (!isValidToken(token, params)) { flash.message = message(code: "forgotPassword.reset.invalidToken") redirect controller: 'forgotPassword', action: 'index' return } render view:'/forgotPassword/reset', model: [token: token.token] } } I've written a unit test for the controller: class TokenControllerTests extends ControllerUnitTestCase { void testPasswordResetInvalidTokenRedirect() { controller.passwordReset() assert... } } Since the message taglib is called in the controller I get a MissingMethodException: groovy.lang.MissingMethodException: No signature of method: TokenController.message() is applicable for argument types: (java.util.LinkedHashMap) values: [[code:forgotPassword.reset.invalidToken]] Does anyone know the best way to get around this issue in a unit test? Ideally I would like to perform assertions on the message but right now I'd be happy if the test just ran! Thanks

    Read the article

  • Error when pushing to Heroku - ...appear in group - Ruby on Rails

    - by bgadoci
    I am trying to deploy my first rails app to Heroku and seem to be having a problem. After git push heroku master, and heroku rake db:migrate I get an error saying: SELECT posts.*, count(*) as vote_total FROM "posts" INNER JOIN "votes" ON votes.post_id = posts.id GROUP BY votes.post_id ORDER BY created_at DESC LIMIT 5 OFFSET 0): I have included the full error below and also included the PostControll#index as it seems that is where I am doing the grouping. Lastly I included my routes.rb file. I am new to ruby, rails, and heroku so sorry for simple/obvious questions. Processing PostsController#index (for 99.7.50.140 at 2010-04-21 12:50:47) [GET] ActiveRecord::StatementInvalid (PGError: ERROR: column "posts.id" must appear in the GROUP BY clause or be used in an aggregate function : SELECT posts.*, count(*) as vote_total FROM "posts" INNER JOIN "votes" ON votes.post_id = posts.id GROUP BY votes.post_id ORDER BY created_at DESC LIMIT 5 OFFSET 0): vendor/gems/will_paginate-2.3.12/lib/will_paginate/finder.rb:82:in `send' vendor/gems/will_paginate-2.3.12/lib/will_paginate/finder.rb:82:in `paginate' vendor/gems/will_paginate-2.3.12/lib/will_paginate/collection.rb:87:in `create' vendor/gems/will_paginate-2.3.12/lib/will_paginate/finder.rb:76:in `paginate' app/controllers/posts_controller.rb:28:in `index' /home/heroku_rack/lib/static_assets.rb:9:in `call' /home/heroku_rack/lib/last_access.rb:25:in `call' /home/heroku_rack/lib/date_header.rb:14:in `call' thin (1.0.1) lib/thin/connection.rb:80:in `pre_process' thin (1.0.1) lib/thin/connection.rb:78:in `catch' thin (1.0.1) lib/thin/connection.rb:78:in `pre_process' thin (1.0.1) lib/thin/connection.rb:57:in `process' thin (1.0.1) lib/thin/connection.rb:42:in `receive_data' eventmachine (0.12.6) lib/eventmachine.rb:240:in `run_machine' eventmachine (0.12.6) lib/eventmachine.rb:240:in `run' thin (1.0.1) lib/thin/backends/base.rb:57:in `start' thin (1.0.1) lib/thin/server.rb:150:in `start' thin (1.0.1) lib/thin/controllers/controller.rb:80:in `start' thin (1.0.1) lib/thin/runner.rb:173:in `send' thin (1.0.1) lib/thin/runner.rb:173:in `run_command' thin (1.0.1) lib/thin/runner.rb:139:in `run!' thin (1.0.1) bin/thin:6 /usr/local/bin/thin:20:in `load' /usr/local/bin/thin:20 PostsController def index @tag_counts = Tag.count(:group => :tag_name, :order => 'count_all DESC', :limit => 20) conditions, joins = {}, :votes @ugtag_counts = Ugtag.count(:group => :ugctag_name, :order => 'count_all DESC', :limit => 20) conditions, joins = {}, :votes @vote_counts = Vote.count(:group => :post_title, :order => 'count_all DESC', :limit => 20) conditions, joins = {}, :votes unless(params[:tag_name] || "").empty? conditions = ["tags.tag_name = ? ", params[:tag_name]] joins = [:tags, :votes] end @posts=Post.paginate( :select => "posts.*, count(*) as vote_total", :joins => joins, :conditions=> conditions, :group => "votes.post_id", :order => "created_at DESC", :page => params[:page], :per_page => 5) @popular_posts=Post.paginate( :select => "posts.*, count(*) as vote_total", :joins => joins, :conditions=> conditions, :group => "votes.post_id", :order => "vote_total DESC", :page => params[:page], :per_page => 3) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @posts } format.json { render :json => @posts } format.atom end end routes.rb ActionController::Routing::Routes.draw do |map| map.resources :ugtags map.resources :wysihat_files map.resources :users map.resources :votes map.resources :votes, :belongs_to => :user map.resources :tags, :belongs_to => :user map.resources :ugtags, :belongs_to => :user map.resources :posts, :collection => {:auto_complete_for_tag_tag_name => :get } map.resources :posts, :sessions map.resources :posts, :has_many => :comments map.resources :posts, :has_many => :tags map.resources :posts, :has_many => :ugtags map.resources :posts, :has_many => :votes map.resources :posts, :belongs_to => :user map.resources :tags, :collection => {:auto_complete_for_tag_tag_name => :get } map.resources :ugtags, :collection => {:auto_complete_for_ugtag_ugctag_name => :get } map.login 'login', :controller => 'sessions', :action => 'new' map.logout 'logout', :controller => 'sessions', :action => 'destroy' map.root :controller => "posts" map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' end UPDATE TO SHOW MODEL AND MIGRATION FOR POST class Post < ActiveRecord::Base has_attached_file :photo validates_presence_of :body, :title has_many :comments, :dependent => :destroy has_many :tags, :dependent => :destroy has_many :ugtags, :dependent => :destroy has_many :votes, :dependent => :destroy belongs_to :user after_create :self_vote def self_vote # I am assuming you have a user_id field in `posts` and `votes` table. self.votes.create(:user => self.user) end cattr_reader :per_page @@per_page = 10 end migrations for post class CreatePosts < ActiveRecord::Migration def self.up create_table :posts do |t| t.string :title t.text :body t.timestamps end end def self.down drop_table :posts end end _ class AddUserIdToPost < ActiveRecord::Migration def self.up add_column :posts, :user_id, :string end def self.down remove_column :posts, :user_id end end

    Read the article

  • Is it good or bad practice to use var everywhere? [closed]

    - by Earlz
    Possible Duplicate: Use of var keyword in C# Hello, I've recently been discovering the awesomeness that is the var keyword in C#. Well, I didn't think about it before but I just wrote lines of code that are along the lines of var con=CreateNewConnection(); Where this would usually be IdbConnection con=CreateNewConnection(); Is this a good use of var? Is it possible to use var too often? Are there any downsides to using it? Also, one more point of consideration: We are not worried about backwards compatability. We just care that it runs on .NET 3.5

    Read the article

  • cakephp and SQL_CALC_FOUND_ROWS

    - by Lizard
    I am trying to add the SQL_CALC_FOUND_ROWS into a query (Please note this isn't for pagination) please note I am trying to add this to a cakePHP query the code I currently have is below: return $this->find('all', array( 'conditions' => $conditions, 'fields'=>array('SQL_CALC_FOUND_ROWS','Category.*','COUNT(`Entity`.`id`) as `entity_count`'), 'joins' => array('LEFT JOIN `entities` AS Entity ON `Entity`.`category_id` = `Category`.`id`'), 'group' => '`Category`.`id`', 'order' => $sort, 'limit'=>$params['limit'], 'offset'=>$params['start'], 'contain' => array('Domain' => array('fields' => array('title'))) )); Note the 'fields'=>array('SQL_CALC_FOUND_ROWS',' this obviously doesn't work as It tries to apply the SQL_CALC_FOUND_ROWS to the table e.g. SELECTCategory.SQL_CALC_FOUND_ROWS, Is there anyway of doing this? Any help would be greatly appreciated, thanks.

    Read the article

  • How to implement a Counter Cache in Rails?

    - by yuval
    I have a posts controller and a comments controller. Post has many comments, and comments belong to Post. The associate is set up with the counter_cache option turned on as such: #Inside post.rb has_many :comments #Inside comment.rb belongs_to :post, :counter_cache => true I have a comments_count column in my posts table that is defaulted to zero, as such: add_column :posts, :comments_count, :integer, :default => 0 In the create action of my comments controller, I have the following code: def create @posts = Post.find(params[:post_id]) @comment = @post.comments.build(params[:comment]) if @comment.save redirect_to root else render :action => 'new' end end My problem: when @comment.save is called, I get the following error: ArgumentError in CommentsController#create wrong number of arguments (2 for 0) Removing :counter_cache => true from comment.rb completely solves the problem, so I'm assuming that it is the cause of this vague error. What am I missing here? How can I save my comment and still have rails take care of my counter_cache for my post? Thanks!

    Read the article

  • Can't locate in @inc during CPAN dependency install performed not as root.

    - by garrett
    While trying to do: perl -I'/v1/data/site_perl' -MCPAN -e 'install Log::Dispatch'; I continue to get "Can't locate Params/Validate.pm in @INC." When looking at the output, /v1/data/site_perl is NOT in the @INC displayed, even though I used -I. I am not root so I have changed my CPAN config so that: 'makepl_arg' => q[LIB=/v1/data/site_perl INSTALLSITEMAN1DIR=/v1/data/site_perl/man/man1 INSTALLSITEMAN3DIR=/v1/data/site_perl/man/man3 INSTALLMAN1DIR=/v1/data/site_perl/man/man1 INSTALLMAN3DIR=/v1/data/site_perl/man/man3] So even LIB is set. In a basic script I have: use lib '/v1/data/site_perl'; use Params::Validate; With no problems. How do I make the Log::Dispatch use lib /v1/data/site_perl without a force install? What am I missing?

    Read the article

  • Capistrano configuration

    - by Eli
    I'm having some issues with variable scope with the capistrano-ext gem's multistage module. I currently have, in config/deploy/staging.rb. set(:settings) { YAML.load_file("config/deploy.yml")['staging'] } set :repository, settings["repository"] set :deploy_to, settings["deploy_to"] set :branch, settings["branch"] set :domain, settings["domain"] set :user, settings["user"] role :app, domain role :web, domain role :db, domain, :primary => true My config/deploy/production.rb file is similar. This doesn't seem very DRY. Ideally, I think I'd like everything to be in the deploy.rb file. If there were a variable set with the current stage, everything would be really clean. UPDATE: I found a solution. I defined this function in deploy.rb: def set_settings(params) params.each_pair do |k,v| set k.to_sym, v end if exists? :domain role :app, domain role :web, domain role :db, domain, :primary => true end end Then my staging.rb file is just set_settings(YAML.load_file("config/deploy.yml")['staging'])

    Read the article

  • Setting up java configurations in eclipse..Param files

    - by Charlie
    I'm going to be using ECJ for doing genetic programming and I haven't touched java in years. I'm working on setting up the eclipse environment and I'm catching a few snags. The ECJ source has several packages, and several sample programs come along with it. I ran one sample program (called tutorial1) by going to the run configurations and adding -file pathToParamsFile to the program arguments. This made it point to the params file of that tutorial and run that sample. In a new example I am testing (from the package gui) there are TWO params files. I tried pointing to just one param file and a program ran in the console, but there was supposed to be a GUI which did not load. I'm not sure what I'm doing wrong. Any help would be greaaatly appreciated.

    Read the article

  • url template tag in django template

    - by user192048
    guys: I was trying to use the url template tag in django, but no lucky, I defined my urls.py like this urlpatterns = patterns('', url(r'^analyse/$', views.home, name="home"), url(r'^analyse/index.html', views.index, name="index"), url(r'^analyse/setup.html', views.setup, name="setup"), url(r'^analyse/show.html', views.show, name="show"), url(r'^analyse/generate.html', views.generate, name="generate"), I defined the url pattern in my view like this {% url 'show'%} then I got this error message Caught an exception while rendering: Reverse for ''show'' with arguments '()' and keyword arguments '{}' not found. Original Traceback (most recent call last): File "/Library/Python/2.5/site-packages/django/template/debug.py", line 71, in render_node result = node.render(context) File "/Library/Python/2.5/site-packages/django/template/defaulttags.py", line 155, in render nodelist.append(node.render(context)) File "/Library/Python/2.5/site-packages/django/template/defaulttags.py", line 382, in render raise e NoReverseMatch: Reverse for ''show'' with arguments '()' and keyword arguments '{}' not found. I am wondering why django failed to render? what is the right way to define it in the tempalte?

    Read the article

  • create table from another table in different database in sql server 2005

    - by Greg
    Hi, I have a database "temp" with table "A". I created new database "temp2". I want to copy table "A" from "temp" to a new table in "temp2" . I tried this statement but it says I have incorrect syntax, here is the statement: CREATE TABLE B IN 'temp2' AS (SELECT * FROM A IN 'temp'); Here is the error: Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'IN'. Msg 156, Level 15, State 1, Line 3 Incorrect syntax near the keyword 'IN'. Anyone knows whats the problem? Thanks in advance, Greg

    Read the article

  • I don't get prices with Amazon Product Advertising API

    - by Xarem
    I try to get prices of an ASIN number with the Amazon Product Advertising API. Code: $artNr = "B003TKSD8E"; $base_url = "http://ecs.amazonaws.de/onca/xml"; $params = array( 'AWSAccessKeyId' => self::API_KEY, 'AssociateTag' => self::API_ASSOCIATE_TAG, 'Version' => "2010-11-01", 'Operation' => "ItemLookup", 'Service' => "AWSECommerceService", 'Condition' => "All", 'IdType' => 'ASIN', 'ItemId' => $artNr); $params['Timestamp'] = gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time()); $url_parts = array(); foreach(array_keys($params) as $key) $url_parts[] = $key . "=" . str_replace('%7E', '~', rawurlencode($params[$key])); sort($url_parts); $url_string = implode("&", $url_parts); $string_to_sign = "GET\necs.amazonaws.de\n/onca/xml\n" . $url_string; $signature = hash_hmac("sha256", $string_to_sign, self::API_SECRET, TRUE); $signature = urlencode(base64_encode($signature)); $url = $base_url . '?' . $url_string . "&Signature=" . $signature; $response = file_get_contents($url); $parsed_xml = simplexml_load_string($response); I think this should be correct - but I don't get offers in the response: SimpleXMLElement Object ( [OperationRequest] => SimpleXMLElement Object ( [RequestId] => ************************* [Arguments] => SimpleXMLElement Object ( [Argument] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [Name] => Condition [Value] => All ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [Name] => Operation [Value] => ItemLookup ) ) [2] => SimpleXMLElement Object ( [@attributes] => Array ( [Name] => Service [Value] => AWSECommerceService ) ) [3] => SimpleXMLElement Object ( [@attributes] => Array ( [Name] => ItemId [Value] => B003TKSD8E ) ) [4] => SimpleXMLElement Object ( [@attributes] => Array ( [Name] => IdType [Value] => ASIN ) ) [5] => SimpleXMLElement Object ( [@attributes] => Array ( [Name] => AWSAccessKeyId [Value] => ************************* ) ) [6] => SimpleXMLElement Object ( [@attributes] => Array ( [Name] => Timestamp [Value] => 2011-11-29T01:32:12.000Z ) ) [7] => SimpleXMLElement Object ( [@attributes] => Array ( [Name] => Signature [Value] => ************************* ) ) [8] => SimpleXMLElement Object ( [@attributes] => Array ( [Name] => AssociateTag [Value] => ************************* ) ) [9] => SimpleXMLElement Object ( [@attributes] => Array ( [Name] => Version [Value] => 2010-11-01 ) ) ) ) [RequestProcessingTime] => 0.0091540000000000 ) [Items] => SimpleXMLElement Object ( [Request] => SimpleXMLElement Object ( [IsValid] => True [ItemLookupRequest] => SimpleXMLElement Object ( [Condition] => All [IdType] => ASIN [ItemId] => B003TKSD8E [ResponseGroup] => Small [VariationPage] => All ) ) [Item] => SimpleXMLElement Object ( [ASIN] => B003TKSD8E [DetailPageURL] => http://www.amazon.de/Apple-iPhone-4-32GB-schwarz/dp/B003TKSD8E%3FSubscriptionId%3DAKIAI6NFQHK2DQIPRUEQ%26tag%3Dbanholzerme-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB003TKSD8E [ItemLinks] => SimpleXMLElement Object ( [ItemLink] => Array ( [0] => SimpleXMLElement Object ( [Description] => Add To Wishlist [URL] => http://www.amazon.de/gp/registry/wishlist/add-item.html%3Fasin.0%3DB003TKSD8E%26SubscriptionId%3DAKIAI6NFQHK2DQIPRUEQ%26tag%3Dbanholzerme-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB003TKSD8E ) [1] => SimpleXMLElement Object ( [Description] => Tell A Friend [URL] => http://www.amazon.de/gp/pdp/taf/B003TKSD8E%3FSubscriptionId%3DAKIAI6NFQHK2DQIPRUEQ%26tag%3Dbanholzerme-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB003TKSD8E ) [2] => SimpleXMLElement Object ( [Description] => All Customer Reviews [URL] => http://www.amazon.de/review/product/B003TKSD8E%3FSubscriptionId%3DAKIAI6NFQHK2DQIPRUEQ%26tag%3Dbanholzerme-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB003TKSD8E ) [3] => SimpleXMLElement Object ( [Description] => All Offers [URL] => http://www.amazon.de/gp/offer-listing/B003TKSD8E%3FSubscriptionId%3DAKIAI6NFQHK2DQIPRUEQ%26tag%3Dbanholzerme-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB003TKSD8E ) ) ) [ItemAttributes] => SimpleXMLElement Object ( [Manufacturer] => Apple Computer [ProductGroup] => CE [Title] => Apple iPhone 4 32GB schwarz ) ) ) ) Can someone please explain me why I don't get any price-information? Thank you very much

    Read the article

  • Extract paragraphs from Wikipedia API using PHP cURL

    - by Kane
    Here's what I'm trying to do using the Wikipedia (MediaWiki) API - http://en.wikipedia.org/w/api.php Do a GET on http://en.wikipedia.org/w/api.php?format=xml&action=opensearch&search=[keyword] to retrieve a list of suggested pages for the keyword Loop through each suggested page using a GET on http://en.wikipedia.org/w/api.php?format=json&action=query&export&titles=[page title] Extract any paragraphs found on the page into an array Do something with the array I'm stuck on #3. I can see a bunch of JSON data that includes "\n\n" between paragraphs, but for some reason the PHP explode() function doesn't work. Essentially I just want to grab the "meat" of each Wikipedia page (not titles or any formatting, just the content) and break it by paragraph into an array. Any ideas? Thanks!

    Read the article

  • Problem updating a database field from my controller

    - by ben
    I have an update method in my users controller that I call from a HTTPService in Flex 4. The update method is as follows: def updateName @user = User.find_by_email(params[:email]) @user.name = params[:nameNew] render :nothing => true end This is console output: Processing UsersController#updateName (for 127.0.0.1 at 2010-05-24 14:12:49) [POST] Parameters: {"action"="updateName", "nameNew"="ben", "controller"="users", "email"="[email protected]"} User Load (0.6ms) SELECT * FROM "users" WHERE ("users"."email" = '[email protected]') LIMIT 1 Completed in 20ms (View: 1, DB: 1) | 200 OK [http://localhost/users/updateName] But when I check my database, the name field is never updated. What am I doing wrong? Thanks for reading.

    Read the article

  • SOAP to XML conversion in PHP

    - by Jonah
    I need to generate the following XML with SOAP: ... <InternationalShippingServiceOption> <ShippingService>StandardInternational</ShippingService> <ShippingServiceCost currencyID="USD">39.99</ShippingServiceCost> <ShippingServicePriority>1</ShippingServicePriority> <ShipToLocation>CA</ShipToLocation> </InternationalShippingServiceOption> ... So I have the following SOAP array in PHP to do this: $params = array( 'InternationalShippingServiceOption' => array( 'ShippingService'=>'StandardInternational', 'ShippingServiceCost'=>39.99, 'ShippingServicePriority'=>1, 'ShipToLocation'=>'CA', ) ) $client = new eBaySOAP($session); //eBaySOAP extends SoapClient $results = $client->AddItem($params); Everything works great, except I am not generating the currencyID="USD" attribute in the ShippingServiceCost tag in the XML. How do I do this?

    Read the article

  • Finding related tags using acts-as-taggable-on

    - by user284194
    In tag#show I list all entries with that tag. At the bottom of the page I'd like to have something like: "Related Tags: linked, list, of, related tags" My view looks like: <h2><%= link_to 'Tag', tags_path %>: <%= @tag.name.titleize %></h2> <% @entries.each do |entry| %> <h2><%= link_to h(entry.name), entry %></h2> <%- unless entry.phone.empty? -%> <p><%= h(entry.phone) %></p> <%- end -%> <%- unless entry.address.empty? -%> <p><%= h(entry.address) %></p> <%- end -%> <%- unless entry.description.empty? -%> <p><%= h(entry.description) %></p> <%- end -%> <p2><%= link_to "more...", entry %><p2> <% end %> Related Tags: <% @related.each do |tag| %> <%= link_to h(tag.tags), tag %> <% end %> tags_controller.rb: def show @title = Tag.find(params[:id]).name @tag = Tag.find(params[:id]) @entries = Entry.paginate(Entry.find_tagged_with(@tag), :page => params[:page], :per_page => 10, :order => "name") @related = Entry.tagged_with(@tag, :on => :tags) end Every entry has at least one tag, it's required by the entry model. I'd like duplicate tags ignored and the current tag (the tag that the list belongs to) ignored. My current code displays this: Related Tags: Gardens Gardens ToursGardens Gardens is a link to the entry, not the tag gardens. ToursGardens is a link to the entry that includes those tags. My desired result would be: Related Tags: Gardens, Tours Each link would link to it's associated tag. Can anyone help me achieve this? I tried using a div_for but I don't think that was right.

    Read the article

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

    - by JZ
    github url 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? Model: def self.search(search) if search find(:all, :conditions => ['address LIKE ?', "%#{search}%"]) # where('address LIKE ?', "%#{search}") else find(:all) end end

    Read the article

  • Setting Application.Handle as a top-level window' owner

    - by Serg
    I want the main form to appear above some other application forms (in z-order), so I override CreateParams method for these forms as follows: procedure TForm3.CreateParams(var Params: TCreateParams); begin inherited; Params.WndParent:= Application.Handle; end; I know the Application.Handle was the top-level windows' owner before Vista (and Delphi 2007). What is wrong with it in Vista (and Windows 7)? What potential problems may arise if I set Application.Handle as a top-level window owner?

    Read the article

  • the rmagick manual is quite vague. can you help me by changing a pictures filetype and size?

    - by Joern Akkermann
    Hi, it's about RMagick with Ruby On Rails. I do the following: image = params[:image] # params[:image] is the image from the file-form. name = image.original_filename.scan(/[^\/\\]+/).last name = dir + t.day.to_s + t.month.to_s + t.year.to_s + t.hour.to_s + t.min.to_s + t.sec.to_s + name f = File.new(name, "wb") f.write image f.close image = Magick::Image.read(name) image = image.resize_to_fit(200, 250) f = File.new(name, "wb") f.write image.to_blob f.close Do I really need to first save and then change it? And how about changing not only the size, changing also the Filetype? I want a JPG with 60% quality. Please help me. Yours, Joern.

    Read the article

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