Search Results

Search found 13838 results on 554 pages for 'disconnected model'.

Page 77/554 | < Previous Page | 73 74 75 76 77 78 79 80 81 82 83 84  | Next Page >

  • Rails: id field is nil when calling Model.new

    - by Joe Cannatti
    I am a little confused about the auto-increment id field in rails. I have a rails project with a simple schema. When i check the development.sqlite3 I can see that all of my tables have an id field with auto increment. CREATE TABLE "messages" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "text" text, "created_at" datetime, "updated_at" datetime); but when i call Message.new on the console, the resulting object has an id of nil >> a = Message.new => #<Message id: nil, text: nil, created_at: nil, updated_at: nil> shouldn't the id come back populated?

    Read the article

  • Rails: associate model with two of its kind

    - by Patrick Oscity
    hi all, im trying to do this: class Event < ActiveRecord::Base belongs_to :previous_event has_one :event, :as => :previous_event, :foreign_key => "previous_event_id" belongs_to :next_event has_one :event, :as => :next_event, :foreign_key => "next_event_id" end because i want to enable the user to repeat events and change multiple oncoming events at the same time. what am i doing wrong, or is there another way of doing this? somehow i need to know about the previous and the next event, don't i? when i'm testing this in the consolewith Event.all[1].previous_event, i get the following error: NameError: uninitialized constant Event::PreviousEvent from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:105:in `const_missing' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2199:in `compute_type' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2195:in `compute_type' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/reflection.rb:156:in `send' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/reflection.rb:156:in `klass' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/belongs_to_association.rb:49:in `find_target' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_proxy.rb:239:in `load_target' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_proxy.rb:112:in `reload' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations.rb:1250:in `previous_event' from (irb):2 what is going wrong here? thanks a ton for your help.

    Read the article

  • Reduce the number of additional Queries to 0 by overriding functions in the base model

    - by user334017
    my basic database setup is: User:... Info: relations: User: { foreignType:one } When displaying information on the user it takes: 1 query to find info on the user, and 1 query to find additional info I want to reduce this to one query that finds both, I assume I need to override a function from BaseUser.class.php, or something along those lines but I'm not really sure what to do. Thanks!

    Read the article

  • How to save to two tables using one SQLAlchemy model

    - by Oatman
    I have an SQLAlchemy ORM class, linked to MySQL, which works great at saving the data I need down to the underlying table. However, I would like to also save the identical data to a second archive table. Here's some psudocode to try and explain what I mean my_data = Data() #An ORM Class my_data.name = "foo" #This saves just to the 'data' table session.add(my_data) #This will save it to the identical 'backup_data' table my_data_archive = my_data my_data_archive.__tablename__ = 'backup_data' session.add(my_data_archive) #And commits them both session.commit() Just a heads up, I am not interested in mapping a class to a JOIN, as in: http://www.sqlalchemy.org/docs/05/mappers.html#mapping-a-class-against-multiple-tables

    Read the article

  • RESTful API: How to model 'request new password'?

    - by Jan P.
    I am designing a RESTful API for a booking application and was quite happy to see I could map all details of the application to the 4 HTTP methods. /users - GET, POST /users/({id}|myself) - GET, POST, PUT, DELETE /users/({id}|myself)/bookings - GET, POST /users/({id}|myself)/bookings/{id} - GET, POST, PUT, DELETE Example: Updating my own user uses a PUT to /users/myself. But now I found out that one thing is missing: The possibility to request a new password if I forgot my old one. Any idea how I could add this?

    Read the article

  • jQuery model-view-controller vs Spring MVC

    - by user1515968
    my question is what potential problems or difficulties would be with implementing usual web app with somewhat reach user interface (multiple dynamic tabs, accordians and so on) using jQuery MVC approach with Spring REST vs using Spring MVC. Problems what I can think of could be: I will not be able to use Spring security fully, JavaScript coding could become hard to manage, any form verification becomes not easy to manage... what else? and does jQuery MVC with REST make sense at all? On other side jQuery with MVC and REST move all GUI concerns to JavaScript side (whether it is bad or not) and leave all data manipulation to server side.

    Read the article

  • How to model file system operations with REST?

    - by massive
    There are obvious counterparts for some of file systems' basic operations (eg. ls and rm), but how would you implement not straightforwardly RESTful actions such as cp or mv? As answers to the question REST services - exposing non-data “actions” suggest, the preferred way of implementing cp would include GETting the resource, DELETing it and PUTting it back again with a new name. But what if I would need to do it efficiently? For instance, if the resource's size would be huge? How would I eliminate the superfluous transmission of resource's payload to client and back to the originating server? Here is an illustration. I have a resource: /videos/my_videos/2-gigabyte-video.avi and I want copy it into a new resource: /videos/johns_videos/copied-2-gigabyte-video.avi How would I implement the copy, move or other file system actions the RESTful way? Or is there even a proper way? Am I doing it all wrong?

    Read the article

  • MVC + Repository Pattern - Still depends on Data Model?

    - by Jack
    I've started a project for school in which I am using ASP.NET MVC 2 + LINQ2SQL, and a business layer so my UI doesnt interact with the DB directly. My question is this: In my MVC project, when bringing up views and passing around data, I still have to include my Data project for access to the classes in my Linq2Sql project. Is this correct? Example: Controller: ClassesRepository cr = new ClassesRepository(); // this is from my Business project Class classToEdit = cr.GetByClassId(id); // "Class" is from my data project I still have to reference the Class class in my linq2sql data project - shouldn't my UI be completely independent of my data layer? Or maybe I'm going about this all wrong.

    Read the article

  • Yii Many_Many Relationship and Form

    - by Thorpe Obazee
    // Post model return array( 'categories' => array(self::HAS_MANY, 'Category', 'posts_categories(post_id, category_id)') ); I already have the setup of tables posts id, title, content categories id, name posts_categories post_id, category_i The problem I have is that I am getting an error when creating this form: <?php $form=$this->beginWidget('CActiveForm', array( 'id'=>'post-form', 'enableAjaxValidation'=>false, )); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <div class="row"> <?php echo $form->labelEx($model,'title'); ?> <?php echo $form->textField($model,'title',array('size'=>60,'maxlength'=>255)); ?> <?php echo $form->error($model,'title'); ?> </div> <div class="row"> <?php echo $form->labelEx($model,'uri'); ?> <?php echo $form->textField($model,'uri',array('size'=>60,'maxlength'=>255)); ?> <?php echo $form->error($model,'uri'); ?> </div> <div class="row"> <?php echo $form->labelEx($model,'content'); ?> <?php echo $form->textArea($model,'content',array('rows'=>6, 'cols'=>50)); ?> <?php echo $form->error($model,'content'); ?> </div> <div class="row"> <?php // echo $form->labelEx($model,'content'); ?> <?php echo CHtml::activeDropDownList($model,'category_id', CHtml::listData(Category::model()->findAll(), 'id', 'name')); ?> <?php // echo $form->error($model,'content'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?> </div> <?php $this->endWidget(); ?> The error is: Property "Post.category_id" is not defined. I am quite confused. What should I be doing to correct this?

    Read the article

  • ASP.NET MVC Access model data in masterpage

    - by Paul
    I have created a UserSiteBaseController that gets commonly used data and sets the data to a UserSiteBaseViewData viewmodel in a method called SetViewData public T CreateViewData<T>() where T : UserSiteBaseViewData, new() { .... } I then create specific Controllers that inherit from the UserSiteBaseController as well as viewModels that inherit from UserSiteHomeViewData and can be created in the controller like so: public ActionResult Index(string slug) { Slug = slug; var viewData = CreateUserSiteHomeViewData<UserSiteHomeViewData>(); //If invalid slug - throw 404 not found if (viewData == null) return PageNotFound(); viewData.Announcements = _announcementsData.All(slug).ToList(); return View(viewData); } private T CreateUserSiteHomeViewData<T>() where T : UserSiteHomeViewData, new() { T viewData = CreateViewData<T>(); return viewData; } The UserBaseViewData holds data that needs to be use on every page so it would be great to be able to access this data from the Masterpage in a strongly typed manner. Is this possible or am I going about this in the incorrect manner?

    Read the article

  • Trying to pass variable from 1 Function to Another to Put in Array within same Model

    - by Jason Shultz
    Ok, that sounds really confusing. What I’m trying to do is this. I’ve got a function that uploads/resizes photos to the server. It stores the paths in the DB. I need to attach the id of the business to the row of photos. Here’s what I have so far: function get_bus_id() { $userid = $this->tank_auth->get_user_id(); $this->db->select('b.id'); $this->db->from ('business AS b'); $this->db->where ('b.userid', $userid); $query = $this->db->get(); if ($query->num_rows() > 0) { return $query->result_array(); } That get’s the id of the business. Then, I have my upload function which is below: /* Uploads images to the site and adds to the database. */ function do_upload() { $config = array( 'allowed_types' => 'jpg|jpeg|gif|png', 'upload_path' => $this->gallery_path, 'max_size' => 2000 ); $this->load->library('upload', $config); $this->upload->do_upload(); $image_data = $this->upload->data(); $config = array( 'source_image' => $image_data['full_path'], 'new_image' => $this->gallery_path . '/thumbs', 'maintain_ratio' => true, 'width' => 150, 'height' => 100 ); $this->load->library('image_lib', $config); $this->image_lib->resize(); $upload = $this->upload->data(); $bus_id = $this->get_bus_id(); $data = array( 'userid' => $this->tank_auth->get_user_id(), 'thumb' => $this->gallery_path . '/thumbs/' . $upload['file_name'], 'fullsize' => $upload['full_path'], 'busid'=> $bus_id['query'], ); echo var_dump($bus_id); $this->db->insert('photos', $data); } The problem I’m getting is the following: A PHP Error was encountered Severity: Notice Message: Undefined index: id Filename: models/gallery_model.php Line Number: 48 I’ve tried all sorts of ways to get the value over, but my limited knowledge keeps getting in the way. Any help would be really appreciated.

    Read the article

  • passing a parameter from an other model on ruby

    - by MAGE
    I'm very newbie in ruby and need your help. I must save a "Topic" and make it like this : @topic = Topic.new(params[:topic]) But I would like to pass an other information to this topic. It has a field "community_id" that link it to a community. The logged user has this information on his table. How can I pass the "community_id" from the logged user to the "community_id" of the "topic" created ? thx for your help

    Read the article

  • Authenticating model - best practices

    - by zerkms
    I come into ASP.NET from php so the reason why i ask my question is because it's totally different nature of how application works and handles requests. well, i have an exists table with user creditians, such as: id, login, password (sha hashed), email, phone, room i have built custom membership provider so it can handle my own database authentication schema. and now i'm confused, because User.Identity.Name contains only user's login, but not the complete object (i'm using linq2sql to communicate with database and i need in it's User object to work). at php applications i just store user object at some static method at Auth class (or some another), but here at ASP.NET MVC i cannot do this, because static member is shared across all requests and permanent, and not lives within only current request (as it was at php). so my question is: how and where should i retrieve and store linq2sql user object to work with it within current and only current request? (after request processed successfully i expect it will be disposed from memory and on next request will be created again). or i'm following totally wrong way?

    Read the article

  • ASP.NET MVC model state as text

    - by David Moorhouse
    Is there an easy way to get a summary string of the errors that have been added to a controller's modelstate? I'm looking to return this in an Ajax method and want the validation errors etc to be returned to the client (i.e. the view does not exist for this method call). Or do I have to loop through the modelstate and look at each object and extract the error text manually?

    Read the article

  • Silverlight ~ MVVM ~ Dynamic setting of Style property based on model value

    - by eponymous23
    I have a class called Question that represents a question and it's answer. I have an application that renders an ObservableCollection of Question objects. Each Question is rendered as a StackPanel that contains a TextBlock for the question verbiage, and a TextBox for the user to enter in an answer. The questions are rendered using an ItemsControl, and I have initially set the Style of the Questions's StackPanel using a StaticResource key called 'IncorrectQuestion' (defined in UserControl.Resources section of the page). In the UserControl.Resources section, I've also defined a key calld 'CorrectQuestion' which I need to somehow apply to the Question's StackPanel when the user correctly answers the question. My problem is I'm not sure how to dynamically change the Style of the StackPanel, specifically within the constraints of a ViewModel class (i.e. I don't want to put any style selection code in the View's code-behind). My Question class has an IsCorrect property which is accurately being set when the correction is answered. I'd like to somehow reflect the IsCorrect value in the form of a Style selection. How do I do that?

    Read the article

  • Rails creating and updating 2 model records simultaneously

    - by LearnRails
    I have 2 tables product and history product table id name type price location 1 abc electronics $200 aisle1 history table id product_id status 1 1 price changed from $200 to $180 Whenever the product price or location is updated by a user by hitting the update button, 1) the changes should be automatically be reflected in the history status column without the user having to enter that manually. if the price is updated from 200 to 180 then a new history row will be created with new id and the status column will say ' price changed from $200 to $180' if the location is updated from aisle1 to aisle 2 then status displays ' loc changed from ailse1 to aisle 2' I tried to @product = Product.new(params[:product]) @history= History.new(params[:history]) if @product.save @history.new(attributes) == I am not sure of whether this approach is correct I would really appreciate if someone could tell me how the history can be automatically updated in this case.

    Read the article

  • RESTful API: How to model JSON representation?

    - by Jan P.
    I am designing a RESTful API for a booking application. You can request a list of accommodations. And that's where I don't really know how to design the JSON represenation. This is my XML representation: <?xml version="1.0" encoding="utf-8"?> <accommodations> <accommodation> <name>...</name> <category>couch</category> </accommodation> <accommodation> <name>...</name> <category>room</category> </accommodation> <accommodations> My first try to convert this to JSON resulted in this output (1): { "0": { "name": "...", "category": "couch" }, "1": { "name": "...", "category": "room" } } But as I looked how others APIs did it, I found something looking more like this (2): [ { "name": "...", "category": "couch" }, { "name": "...", "category": "room" } ] I know version 1 is an object, and version 2 an array. But which one is better in this case?

    Read the article

  • Java classloader delegation model ?

    - by Tony
    When calling a loadClass() on a class loader, the class loader firstly check the class if had been loaded or directly delegate this check to it's parent class loader ? Java api says: When requested to find a class or resource, a ClassLoader instance will delegate the search for the class or resource to its parent class loader before attempting to find the class or resource itself. But there's a specific chapter about class loader in the book <java reflection in action> and says: Class loader calls findLoadedClass to check if the class has been loaded already.If a class loader does not find a loaded class, calls loadClass on the parent class loader. which is correct ?

    Read the article

  • Avoiding repetition with libraries that use a setup + execute model

    - by lijie
    Some libraries offer the ability to separate setup and execution, esp if the setup portion has undesirable characteristics such as unbounded latency. If the program needs to have this reflected in its structure, then it is natural to have: void setupXXX(...); // which calls the setup stuff void doXXX(...); // which calls the execute stuff The problem with this is that the structure of setupXXX and doXXX is going to be quite similar (at least textually -- control flow will prob be more complex in doXXX). Wondering if there are any ways to avoid this. Example: Let's say we're doing signal processing: filtering with a known kernel in the frequency domain. so, setupXXX and doXXX would probably be something like... void doFilter(FilterStuff *c) { for (int i = 0; i < c->N; ++i) { doFFT(c->x[i], c->fft_forward_setup, c->tmp); doMultiplyVector(c->tmp, c->filter); doFFT(c->tmp, c->fft_inverse_setup, c->x[i]); } } void setupFilter(FilterStuff *c) { setupFFT(..., &(c->fft_forward_setup)); // assign the kernel to c->filter ... setupFFT(..., &(c->fft_inverse_setup)); }

    Read the article

  • Is Appfogs pricing model sustainable?

    - by Kyle Finley
    I was looking at AppFog's Pricing and they appear to be giving 2GB of ram away for free, to nonpaying customers. This seems unprecedented for PAAS provodes--providers like Heroku and App Engine remove the app from memory if it has been inactive for certain amount of time. Does cloudfoundry work similarly? Am I wrong in assuming that in a few years appfog servers will be filled with inactive non paying applications?

    Read the article

  • Limiting records in a model action...

    - by bgadoci
    How do I limit the number of records that I am outputting with the following code to only 3 records: User.rb def workouts_on_which_i_commented comments.map{|x|x.workout}.uniq end def comment_stream workouts_on_which_i_commented.map do |w| w.comments end.flatten.sort{|x,y| y.created_at <=> x.created_at} end html.erb file <% current_user.comment_stream.each do |comment| %> ... <% end %> UPDATE: I'm using Rails 2.3.9

    Read the article

< Previous Page | 73 74 75 76 77 78 79 80 81 82 83 84  | Next Page >