Search Results

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

Page 61/164 | < Previous Page | 57 58 59 60 61 62 63 64 65 66 67 68  | Next Page >

  • Why is 'virtual' optional for overridden methods in derived classes?

    - by squelart
    When a method is declared as virtual in a class, its overrides in derived classes are automatically considered virtual as well, and the C++ language makes this keyword virtual optional in this case: class Base { virtual void f(); }; class Derived : public Base { void f(); // 'virtual' is optional but implied. }; My question is: What is the rationale for making virtual optional? I know that it is not absolutely necessary for the compiler to be told that, but I would think that developers would benefit if such a constraint was enforced by the compiler. E.g., sometimes when I read others' code I wonder if a method is virtual and I have to track down its superclasses to determine that. And some coding standards (Google) make it a 'must' to put the virtual keyword in all subclasses.

    Read the article

  • Are there cheat sheets for misc source code management tools?

    - by Alex_coder
    I'm looking for something similar to Pacman Rosetta, which explains how to achieve similar tasks using different source code management tools. Sometimes docs for a certain SCM contain examples comparing that particular SCM to a couple of others. But I'm looking for a central place that contains maximum available information. Example: one uses bzr and knows that 'bzr pull' syncs a local repo by fetching new content from a remote repo. One want to know how to do that with git. One finds the git command, he knows the keyword. Since the keyword is known, one can proceed straight to git docs, he knows what to read about, he doesn't have to waste time by searching the git docs. I understand this might be not the only way people use to learn a new SCM tool. If you use other approaches, please do tell.

    Read the article

  • Question regrarding declaring a property

    - by Simon
    Hi. We declare properties using the @property keyword and synthesize it in the implementation file. My question is, What if I declare a property using the @property keyword and also declare a variable in the interface block with the same name? For example, consider the following code, Interface: @interface myClass : NSObject { NSString *myClass_name; // LINE 1 } @property(nonatomic, retain) NSString *myClass_name; // LINE 2 @end Implementation: @implementation myClass @synthesize myClass_name @end Declaring myClass_name in LINE 1 will make any problem? Like any reference problem or any unnecessary memory consumption problem?

    Read the article

  • What is the best way to declare a property?

    - by Simon
    Hi. We declare properties using the @property keyword and synthesize it in the implementation file. My question is, What if I declare a property using the @property keyword and also declare a variable in the interface block with the same name? For example, consider the following code, Interface: @interface myClass : NSObject { NSString *myClass_name; // LINE 1 } @property(nonatomic, retain) NSString *myClass_name; // LINE 2 @end Implementation: @implementation myClass @synthesize myClass_name // LINE 3 @end Declaring myClass_name in LINE 1 will make any problem? Like any reference problem or any unnecessary memory consumption problem?

    Read the article

  • Can anyone tell me why my XML writer is not writing attributes?

    - by user1632018
    I am writing a parsing tool to help me clean up a large VC++ project before I make .net bindings for it. I am using an XML writer to read an xml file and write out each element to a new file. If an element with a certain name is found, then it executes some code and writes an output value into the elements value. So far it is almost working, except for one thing: It is not copying the attributes. Can anyone tell me why this is happening? Here is a sample of what it is supposed to copy/modify(Includes the attributes): <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|Win32"> <Configuration>Release</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> </ItemGroup> <PropertyGroup Label="Globals"> <ProjectGuid>{57900E99-A405-49F4-83B2-0254117D041B}</ProjectGuid> <Keyword>Win32Proj</Keyword> <RootNamespace>libproj</RootNamespace> </PropertyGroup> Here is the output I am getting(No Attributes): <?xml version="1.0" encoding="utf-8"?> <Project> <ItemGroup> <ProjectConfiguration> <Configuration>Debug</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> <ProjectConfiguration> <Configuration>Release</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> </ItemGroup> <PropertyGroup> <ProjectGuid>{57900E99-A405-49F4-83B2-0254117D041B}</ProjectGuid> <Keyword>Win32Proj</Keyword> <RootNamespace>libproj</RootNamespace> Here is my code currently. I have tried every way I can come up with to write the attributes. string baseDir = (textBox2.Text + "\\" + safeFileName); string vcName = Path.GetFileName(textBox1.Text); string vcProj = Path.Combine(baseDir, vcName); using (XmlReader reader = XmlReader.Create(textBox1.Text)) { XmlWriterSettings settings = new XmlWriterSettings(); settings.OmitXmlDeclaration = true; settings.ConformanceLevel = ConformanceLevel.Fragment; settings.Indent = true; settings.CloseOutput = false; using (XmlWriter writer = XmlWriter.Create(vcProj, settings)) { while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == "ClInclude") { string include = reader.GetAttribute("Include"); string dirPath = Path.GetDirectoryName(textBox1.Text); Directory.SetCurrentDirectory(dirPath); string fullPath = Path.GetFullPath(include); //string dirPath = Path.GetDirectoryName(fullPath); copyFile(fullPath, 3); string filename = Path.GetFileName(fullPath); writer.WriteStartElement(reader.Name); writer.WriteAttributeString("Include", "include/" + filename); writer.WriteEndElement(); } else if (reader.Name == "ClCompile" && reader.HasAttributes) { string include = reader.GetAttribute("Include"); string dirPath = Path.GetDirectoryName(textBox1.Text); Directory.SetCurrentDirectory(dirPath); string fullPath = Path.GetFullPath(include); copyFile(fullPath, 2); string filename = Path.GetFileName(fullPath); writer.WriteStartElement(reader.Name); writer.WriteAttributeString("Include", "src/" + filename); writer.WriteEndElement(); } else { writer.WriteStartElement(reader.Name); } break; case XmlNodeType.Text: writer.WriteString(reader.Value); break; case XmlNodeType.XmlDeclaration: case XmlNodeType.ProcessingInstruction: writer.WriteProcessingInstruction(reader.Name, reader.Value); break; case XmlNodeType.Comment: writer.WriteComment(reader.Value); break; case XmlNodeType.Attribute: writer.WriteAttributes(reader, true); break; case XmlNodeType.EntityReference: writer.WriteEntityRef(reader.Value); break; case XmlNodeType.EndElement: writer.WriteFullEndElement(); break; } } } }

    Read the article

  • Human readable URL causes a problem in Ruby on Rails

    - by TK
    I have a basic CRUD with "Company" model. To make the company name show up, I did def to_param name.parameterize end Then I accessed http://localhost:3000/companies/american-express which runs show action in the companies controller. Obviously this doesn't work because the show method is as following: def show @company = Company.find_by_id(params[:id]) end The params[:id] is american-express. This string is not stored anywhere. Do I need to store the short string (i.e., "american-express") in the database when I save the record? Or is there any way to retrieve the company data without saving the string in the database?

    Read the article

  • JSON is not nested in rails view

    - by SeanGeneva
    I have a several models in a heirarchy, 1:many at each level. Each class is associated only with the class above it and the one below it, ie: L1 course, L2 unit, L3 unit layout, L4 layout fields, L5 table fields (not in code, but a sibling of layout fields) I am trying to build a JSON response of the entire hierarchy. def show @course = Course.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json do @course = Course.find(params[:id]) @units = @course.units.all @unit_layouts = UnitLayout.where(:unit_id => @units) @layout_fields = LayoutField.where(:unit_layout_id => @unit_layouts) response = {:course => @course, :units => @units, :unit_layouts => @unit_layouts, :layout_fields => @layout_fields} respond_to do |format| format.json {render :json => response } end end end end The code is bring back the correct values, but the units, unit_layouts and layout_fields are all nested at the same level under course. I would like them to be nested inside their parent.

    Read the article

  • Authlogic Help! Registering a new user when currently logged-in as a user not working.

    - by looloobs
    Hi Just as a disclaimer I am new to rails and programming in general so apologize for misunderstanding something obvious. I have Authlogic with activation up and running. So for my site I would like my users who are logged in to be able to register other users. The new user would pick their login and password through the activation email, but the existing user needs to put them in by email, position and a couple other attributes. I want that to be done by the existing user. The problem I am running into, if I am logged in and then try and create a new user it just tries to update the existing user and doesn't create a new one. I am not sure if there is some way to fix this by having another session start??? If that is even right/possible I wouldn't know how to go about implementing it. I realize without knowing fully about my application it may be difficult to answer this, but does this even sound like the right way to go about this? Am I missing something here? Users Controller: class UsersController < ApplicationController before_filter :require_no_user, :only => [:new, :create] before_filter :require_user, :only => [:show, :edit, :update] def new @user = User.new end def create @user = User.new if @user.signup!(params) @user.deliver_activation_instructions! flash[:notice] = "Your account has been created. Please check your e-mail for your account activation instructions!" redirect_to profile_url else render :action => :new end end def show @user = @current_user end def edit @user = @current_user end def update @user = @current_user # makes our views "cleaner" and more consistent if @user.update_attributes(params[:user]) flash[:notice] = "Account updated!" redirect_to profile_url else render :action => :edit end end end My User_Session Controller: class UserSessionsController < ApplicationController before_filter :require_no_user, :only => [:new, :create] before_filter :require_user, :only => :destroy def new @user_session = UserSession.new end def create @user_session = UserSession.new(params[:user_session]) if @user_session.save flash[:notice] = "Login successful!" if @user_session.user.position == 'Battalion Commander' : redirect_to battalion_path(@user_session.user.battalion_id) else end else render :action => :new end end def destroy current_user_session.destroy flash[:notice] = "Logout successful!" redirect_back_or_default new_user_session_url end end

    Read the article

  • What does :this means in Ruby on Rails?

    - by Marco
    Hi, I'm new to the Ruby and Ruby on Rails world. I've read some guides, but i've some trouble with the following syntax. I think that the usage of :condition syntax is used in Ruby to define a class attribute with some kind of accessor, like: class Sample attr_accessor :condition end that implicitly declares the getter and setter for the "condition" property. While i was looking at some Rails sample code, i found the following examples that i don't fully understand. For example: @post = Post.find(params[:id]) Why it's accessing the id attribute with this syntax, instead of: @post = Post.find(params[id]) Or, for example: @posts = Post.find(:all) Is :all a constant here? If not, what does this code really means? If yes, why the following is not used: @posts = Post.find(ALL) Thanks

    Read the article

  • rspec mocking object property assignment

    - by charlielee
    I have a rspec mocked object, a value is assign to is property. I am struggleing to have that expectation met in my rspec test. Just wondering what the sytax is? The code: def create @new_campaign = AdCampaign.new(params[:new_campaign]) @new_campaign.creationDate = "#{Time.now.year}/#{Time.now.mon}/#{Time.now.day}" if @new_campaign.save flash[:status] = "Success" else flash[:status] = "Failed" end end The test it "should able to create new campaign when form is submitted" do campaign_model = mock_model(AdCampaign) AdCampaign.should_receive(:new).with(params[:new_campaign]).and_return(campaign_model) campaign_model.should_receive(:creationDate).with("#{Time.now.year}/#{Time.now.mon}/#{Time.now.day}")campaign_model.should_receive(:save).and_return(true) post :create flash[:status].should == 'Success' response.should render_template('create') end The problem is I am getting this error: Spec::Mocks::MockExpectationError in 'CampaignController new campaigns should able to create new campaign when form is submitted' Mock "AdCampaign_1002" received unexpected message :creationDate= with ("2010/5/7") So how do i set a expectation for object property assignment? Thanks

    Read the article

  • Is it possible with dynamic TSQL query ?

    - by eugeneK
    I have very long select query which i need to filter based on some params, i'm trying to avoid having different stored procedures or if statements inside of single stored procedure by using partly dynamic TSQL... I will avoid long select just for example sake select a from b where c=@c or d=@d @c and @d are filter params, only one can filter at the same time but also both filters could be disabled. 0 for each of these means param is disables so i can create nvarchar with where statement in it... How do i integrate in here dynamic query so 'where' can be added to normal query. I cannot add all the query as big nvarchar because there is too many things in it which will require changes ( ie. when's, subqueries, joins)

    Read the article

  • Rails - Why is my custom validation being triggered for only a build command.

    - by adam
    I have a sentence and correction model with a has_one and belongs_to relationship respectively. For some reason when I do def create @sentence = Sentence.find(params[:sentence_id]) @correction = @sentence.build_correction(params[:correction]) a custom validation I wrote for Correction is being called at the build_correction point. the validation is below class Correction < ActiveRecord::Base attr_accessible :text, :sentence_id, :user_id belongs_to :sentence belongs_to :user validate :correction_is_different_than_sentence def correction_is_different_than_sentence errors.add(:text, "can't be the same as the original sentence.") if (text == self.sentence.text) end the problem is for some reason on validation the correction object doesn't have the sentence id set (despite I used the build_correction method) and so it complains "you have nil object .... while executing nil.text" in the if clause in the validation above. So my question is why is the validation occuring for a build command, i thought it only triggers on a create or update. And why isnt the sentence_id getting set?

    Read the article

  • ferret,multiple model search -undefined method `aaf_index' for #<Class:>

    - by jissy
    ferret,multiple model search - I have 2 models A and B.I want to perform a text search by using 3 fields; title, description(part of A) and comment(part of B). Where I want to include the comment field to perform the ferret search.Then,what other changes needed. class A < ActiveRecord::Base has_one :b acts_as_ferret :fields => [:title, :description], :additional_fields => [:comment_text] def comment_text return b.comment end In a_controller, i wrote: @search = A.find_with_ferret( params[:st][:text_search], :limit => :all, :multi => [B] ).paginate :per_page =>10, :page=>params[:page] The second mosel is given below: class B < ActiveRecord::Base belongs_to :a while using :multi[B] option with the find_with_ferret,the following error is getting: undefined method `aaf_index' for #ClassName

    Read the article

  • Accessing a nested hash in a controller

    - by Magicked
    I have the following (snipped) parameters passed into my controller. Parameters: {"commit"=>"OK", "action"=>"set_incident_incident_status_id", "id"=>"1", "controller"=>"incidents", "incident"=>{"incident_status_id"=>"1"}} I know that if I want to select the incident, I can do: @incident = Incident.find(params[:id]) How do I access the "incident"={"incident_status_id"="1"}? I thought to try something like: @incident_status = IncidentStatus.find(params[:incident => :incident_status_id]) But that didn't work. I'm assuming it's just a syntax problem at this point, and I haven't found a solution yet. Any help would be much appreciated!

    Read the article

  • Rails 3 Create method using nested resources?

    - by user1461119
    How can I clean this up using rails 3 features? I have a post that belongs to a group and also a user. The group and user has_many posts. I am using a nested resource resources :groups do resources :posts end <%= form_for @post, :url => group_posts_path(params[:group_id]) do |f| %> .... <% end %> def create @group = Group.find(1) @post = @group.posts.build(params[:post]) @post.user_id = current_user.id respond_to do |format| if @post.save ..... end end end Thank you.

    Read the article

  • How do I create another controller action to create an object in rails?

    - by Angela
    I have a model called Contact_Email. When an Email template is sent through ActionMailer to a specific Contact, as part of the Create action it sends it through upon .save. However, I want to create a "skip" action which also creates a Contact_Email, but does NOT send an ActionMailer and allows me to set the status differently. I want to create a separate action because I want to make this respond to a remote_for_tag so that I can just have an ajax button indicate it has been "skipped": Here's what I tried, but while it creates a Contact_Email, I end up getting an error when I want to go back and view all the Contacts again. def skip @contact_email = ContactEmail.new @contact_email.contact_id = params[:contact_id] @contact_email.email_id = params[:email_id] @contact_email.status = "skipped" if @contact_email.save flash[:notice] = "skipped email" redirect_to contact_emails_url end end

    Read the article

  • Attributes passed to .build() dont show up in the query

    - by Sebastian
    Hi there guys! Hope your all enjoying your hollydays. Ive run into a pretty funny problem when trying to insert rows into a really really simple database table. The basic idea is pretty simple. The user selects one/multiple users in a multiselect which are supposed to be added to a group. This piece of code will insert a row into the user_group_relationships table, but the users id always @group = Group.find(params[:group_id]) params[:newMember][:users].each do |uid| # For debugging purposes. puts 'Uid:'+uid @rel = @group.user_group_relationships.build( :user_id => uid.to_i ) @rel.save end The user id always gets inserted as null even though it is clearly there. You can see the uid in this example is 5, so it should work. Uid:5 ... SQL (0.3ms) INSERT INTO "user_group_relationships" ("created_at", "group_id", "updated_at", "user_id") VALUES ('2010-12-27 14:03:24.331303', 2, '2010-12-27 14:03:24.331303', NULL) Any ideas why this fails?

    Read the article

  • Fork to shell script and terminate original process with Haskell

    - by Neth
    I am currently writing a Haskell program that does some initialization work and then calls ncmpcpp. What I am trying to do is start ncmpcpp and terminate the Haskell program, so that only ncmpcpp is left (optionally, the program can keep running in the background, as long as it's unintrusive) However, even though I am able to start ncmpcpp, I cannot interact with it. I see its output, but input appears to be impossible. What I am currently doing is: import System.Process (createProcess, proc) ... spawnCurses :: [String] -> IO () spawnCurses params = do _ <- createProcess (proc "ncmpcpp" params) return () What am I doing wrong/What should I do differently?

    Read the article

  • A new Rails idea in views and no more controller. maybe better maybe worse, i need help if this is t

    - by Totty
    Hy, I was thinking that all my website will have use of cells, using the known plugin cell for rails, so this is my idea: A table that contains 3 fields: id, view_name and layout. the layout will be a serialized hash. When a request is made, the layout field is requested and then in the view, default layout, will be unserialized the layout var, that looks like this: @layout[:sidecol][:gallery] = {... some params for it...}; @layout[:maincol][:comments] = {..params...}; In the <% #ruby code to render the cells in the @layout[:sidecol] % will be some ruby code that will loop over the @layout[:sidecol] and render all cells in it. the same occurs in the maincol div. What do you think? Positive in my opinion: More modular controller is used only for post easy change of structure easier to implement some kind of traking to see diferences on what layout is better or not. Negative: not found yet

    Read the article

  • Getting data into MATLAB from HTTPS

    - by yuk
    Anybody know if it's possible? I'm trying to get the data by using the following code url = 'https://cgwb.nci.nih.gov/cgi-bin/hgTracks'; params = {'org','Human','db','hg18','position','EGFR'}; urltxt = urlread(url,'get',params); but get the error ??? Error using ==> urlread at 111 Error downloading URL. Your network connection may be down or your proxy settings improperly configured. If I substitute https to http, it works, but I get "301 Moved Permanently" page with the above https-link. The link in browser works properly in both cases (redirecting http request). The site does not require any authentication. May be there are other ways than urlread?

    Read the article

  • Read Velocity Tokens/Tag from .vm file

    - by user1801660
    I have an application where in I am trying to create a velocity template repository which will help me centralise all my email templates and will allow me to create a communication hub. All templates will be called at runtime and populates with data via services. My problem is that I need to provide users with optional and compulsory params list when they define the template inputs for the velocity template. Is there a way to read the tokens/tags from the velocity template file and extract them?? Like I want a list of tokens $name.address.streetName to be available to me from .vm file. I do not want to go for Regex . I do not have to cache or reuse them , its just going to be a one time read and store the default,compulsory & optional params in the database. I am following these patterns : http://kickjava.com/src/org/apache/velocity/test/view/TemplateNodeView.java.htm How to use String as Velocity Template? Please advice.

    Read the article

  • How to make pytest display a custom string representation for fixture parameters?

    - by Björn Pollex
    When using builtin types as fixture parameters, pytest prints out the value of the parameters in the test report. For example: @fixture(params=['hello', 'world'] def data(request): return request.param def test_something(data): pass Running this with py.test --verbose will print something like: test_example.py:7: test_something[hello] PASSED test_example.py:7: test_something[world] PASSED Note that the value of the parameter is printed in square brackets after the test name. Now, when using an object of a user-defined class as parameter, like so: class Param(object): def __init__(self, text): self.text = text @fixture(params=[Param('hello'), Param('world')] def data(request): return request.param def test_something(data): pass pytest will simply enumerate the number of values (p0, p1, etc.): test_example.py:7: test_something[p0] PASSED test_example.py:7: test_something[p1] PASSED This behavior does not change even when the user-defined class provides custom __str__ and __repr__ implementations. Is there any way to make pytest display something more useful than just p0 here? I am using pytest 2.5.2 on Python 2.7.6 on Windows 7.

    Read the article

  • C++: How do I pass a function(without knowing its parameters) to another function?

    - by Ninja
    Hi all. I'm trying to create a function that will store and repeat another function given as a parameter for a specific amount of time or repeats given. But when you want to pass a function as a parameter you have to know all of its parameters before hand. How would I do if I wanted to pass the function as one parameter, and the parameters as another? void AddTimer(float time, int repeats, void (*func), params); // I know params has no type and that (*func) is missing parameters but it is just to show you what I mean Thanks in advance

    Read the article

  • Using PHP5s SOAP Client to send data to an ASP/.NET based SOAP server.

    - by user325143
    I am trying to write a snippet of PHP to connect to a third party's API via SOAP to enter some data into their database. The API requires me to pass several mandatory fields for every call (username, password, companyid, entitytype) in addition to the mandatory data fields. It also requires me to call the "ValidateEntity" funciton before calling the "CreateEntity" function. Documentation can be found here: http://wiki.agemni.com/Getting_Started/APIs/Database_API I have never worked with SOAP before, so I am very new to this. Here is what I have so far: error_reporting(E_ALL); ini_set('display_errors', '1'); $client = new SoapClient("http://agemni.com/AgemniWebservices/service1.asmx?WSDL", array('trace'=> true)); $options = array( 'username' => "myuser", 'password' => "mypassword", 'companyid' => myID, 'entitytype' => 2 ); $params = array( 'fname' => "John", 'lname' => "Doe", 'phone' => "859-333-3333", 'zip' => "40332", 'area id' => "12345", 'lead id' => "28222", 'contactdate' => "4/10/2010" ); $validate = $client->__soapCall("ValidateEntity", array($params), array($options)); $client->__soapCall("CreateEntity", array($params), array($options)); echo "<pre>"; var_dump($client-> __getLastRequestHeaders()); var_dump($client-> __getLastRequest()); var_dump($client-> __getLastResponseHeaders()); var_dump($client-> __getLastResponse()); var_dump($result); echo "</pre>"; Upon executing this code, I get the following error: Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object hasn't 'objecttype' property in /www/tmp/index-soap.php:24 Stack trace: #0 /www/tmp/index-soap.php(24): SoapClient->__soapCall('ValidateEntity', Array) #1 {main} thrown in /www/stealth/tmp/index-soap.php on line 24 I guess my question is.. am I even going about doing this the right way? I know this is a very broad question, but I appreciate any advice you can give me about making this work. Please let me know if you require more detail. Thanks!

    Read the article

  • Is there a way to ignore Cache errors in Django?

    - by Josh Smeaton
    I've just set our development Django site to use redis for a cache backend and it was all working fine. I brought down redis to see what would happen, and sure enough Django 404's due to cache backend behaviour. Either the Connection was refused, or various other errors. Is there any way to instruct Django to ignore Cache errors, and continue processing the normal way? It seems weird that caching is a performance optimization, but can bring down an entire site if it fails. I tried to write a wrapper around the backend like so: class CacheClass(redis_backend.CacheClass): """ Wraps the desired Cache, and falls back to global_settings default on init failure """ def __init__(self, server, params): try: super(CacheClass, self).__init__(server, params) except Exception: from django.core import cache as _ _.cache = _.get_cache('locmem://') But that won't work, since I'm trying to set the cache type in the call that sets the cache type. It's all a very big mess. So, is there any easy way to swallow cache errors? Or to set the default cache backend on failure?

    Read the article

< Previous Page | 57 58 59 60 61 62 63 64 65 66 67 68  | Next Page >