Search Results

Search found 15231 results on 610 pages for 'presentation model'.

Page 69/610 | < Previous Page | 65 66 67 68 69 70 71 72 73 74 75 76  | Next Page >

  • How to get attribute of a model saved in instance variable

    - by Nazar
    I am writing a plugin, in which i define a new relation dynamically with in plugin. Sample code is given below module AttachDocumentsAs @as = nil def attach_documents_as(*attachment_as) attachment_as = attachment_as.to_a.flatten.compact.map(&:to_sym) @as = attachment_as.first class_inheritable_reader(@as) class_eval do has_many @as, :as => :attachable, :class_name=>"AttachDocuments::Models::AttachedDocument" accepts_nested_attributes_for @as end end end now in any model i used it as class Person < AtiveRecord::Base attach_documents_as :financial_documents end Now want to access want to access this attribute of the class in overloaded initialize method like this def initialize(*args) super(*args) "#{@as}".build end But it is not getting required attribute, can any one help me in it. I want to build this relation and set some initial values. Waiting for guidelines from all you guys.

    Read the article

  • Saving related model objects

    - by iHeartDucks
    I have two related models (one to many) in my django app and When I do something like this ObjBlog = Blog() objBlog.name = 'test blog' objEntry1 = Entry() objEntry1.title = 'Entry one' objEntry2 = Entry() objEntry2.title = 'Entry Two' objBlog.entry_set.add(objEntry1) objBlog.entry_set.add(objEntry2) I get an error which says "null value in column and it violates the foreign key not null constraint". None of my model objects have been saved. Do I have to save the "objBlog" before I could set the entries? I was hoping I could call the save method on objBlog to save it all. NOTE: I am not creating a blog engine and this is just an example.

    Read the article

  • How to change Zend_Db_Table name within a Model to insert in multiple tables

    - by jwhat
    Using Zend Framework, I've created a Model to insert a record into a database. My question is, after $this->insert($data) how can I switch the active table so that I can insert a record into another table? Here's my code so far: class Model_DbTable_Foo extends Zend_Db_Table_Abstract { protected $_name = 'foo'; public function addFoo($params) { $data = array( 'foo' => $params['foo'], ); $this->insert($data); $foo_id = $this->getAdapter()->lastInsertId(); $data2 = array( 'bar' => $params['bar'] ); // I need to change the Db Table name here. $this->insert($data2); $bar_id = $this->getAdapter()->lastInsertId(); } }

    Read the article

  • print hierarchy data(adjacency list model) in a list(ul/ol/li)

    - by adi
    I have adjacency list model like on the page http://dev.mysql.com/tech-resources/articles/hierarchical-data.html i have make a full table containing all data ordered by level using this SELECT t1.name AS lev1, t2.name as lev2, t3.name as lev3, t4.name as lev4 FROM category AS t1 LEFT JOIN category AS t2 ON t2.parent = t1.category_id LEFT JOIN category AS t3 ON t3.parent = t2.category_id LEFT JOIN category AS t4 ON t4.parent = t3.category_id WHERE t1.name = 'ELECTRONICS'; ORDER by ..... I want to make an unordered list using php from the table Anyone can help me...

    Read the article

  • habtm multiple times with the same model

    - by Ermin
    I am trying to model a publications. A publication can have multiple authors and editors. Since it is possible that one person is an author of one publication and an editor of another, no separate models for Authors and Editors: class Publication < ActiveRecord::Base has_and_belongs_to_many :authors, :class_name=>'Person' has_and_belongs_to_many :editors, :class_name=>'Person' end The above code doesn't work, because it uses the same join table. Now I now that I can specify the name of the join table, but there is a warning in the API documentation is a warning about that which I don't understand: :join_table: Specify the name of the join table if the default based on lexical order isn’t what you want. WARNING: If you’re overwriting the table name of either class, the table_name method MUST be declared underneath any has_and_belongs_to_many declaration in order to work.

    Read the article

  • What comes first in Ruby's object model?

    - by Timothy
    I've been reading Metaprogramming Ruby and the object model like the chicken or egg dilemma. In Ruby 1.8, the Object class is an instance of Class. Module's superclass is Object and is an instance of Class. Class' superclass is Module, and it is an instance of Class (self-referential). Say class SomeClass; end is defined somewhere; SomeClass is an instance of Class, however its superclass is Object. Why does an instance of Class have Object as the superclass instead of nil? Also, if Object is to exist, then Class has to exist, but then Module has to exist, but for Module to exist Object has to exist. How are these classes created?

    Read the article

  • Using :limit and :order in the associated model

    - by r2b2
    Hello, Is there any way i can limit the results of an associated model? This what i was trying to do : <ul> <% account.logins.slice(0,5).sort_by(&:login_date).reverse.each do |login| -%> <li><%=h login.login_date.strftime("%d.%m.%Y")%></li> <% end -%> </ul> I'm trying to get the last five logins of the account. I cant seem to do it with account.logins(:limit=5) Thanks !

    Read the article

  • Ruby - model.rb:20: syntax error, unexpected keyword_end, expecting $end

    - by Yasir Adnan
    I don't understand what's wrong with my code. model.rb require 'Gemfile' DataMapper.setup(:default, 'mysql://root:password@localhost/rengine') Class User include DataMapper::Resource property :id, Serial # An auto-increment integer key property :email, String, format: :email_address property :username, String, required: true property :password, String , length: 10..255, required: true property :created_at, DateTime property :updated_at, DateTime #User can have mutiple posts has n, :posts end Class Post include DataMapper::Resource property :id, Serial # An auto-increment integer key property :title, String, required: true property :body, Text, required: true property :created_at, DateTime property :updated_at, DateTime #Posts belongs to a USer belongs_to :user end DataMapper.auto_upgrade! I didn't able to figure out. What's problem is here??

    Read the article

  • JSF - Updating Model Values in Controller Bean

    - by Sean
    I have a Controller bean (SearchController) that has two managed bean as managed properties (SearchCriteria, SearchResults; both of which are session scoped). When the user hits the find button, the action method that is executed is in SearchController. The SearchCreteria managed bean has a method called search(). This method returns a new SearchResults object. In the controller bean, I am setting the searchResults managed property to be this new SearchResults object. The searchResults object contains what I expect during that request, but the object does not persist in the managed bean. I understand that I am changing what object that searchResults is referencing, but what I don't understand is why JSF isn't updating the model to use the new object. Any ideas what I'm missing or don't understand? I am using JSF 1.1 on WebSphere 6.1. If I put the search method in the SearchResults managed bean, it works.

    Read the article

  • Include a Class in another model / class / lib

    - by jaycode
    I need to use function "image_path" in my lib class. I tried this (and couple of other variations): class CustomHelpers::Base include ActionView::Helpers::AssetTagHelper def self.image_url(source) abs_path = image_path(source) unless abs_path =~ /^http/ abs_path = "#{request.protocol}#{request.host_with_port}#{abs_path}" end abs_path end end But it didn't work. Am I doing it right? Another question is, how do I find the right class to include? For example if I look at this module: http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html is there a rule of thumb how to include that module in a model / library / class / anything else ?

    Read the article

  • Animate 3D model programmatically-where to start?

    - by amile
    I am having a task to create a 3D model face that can talk like humans.without having any knowledge about 3D modeling. I have no clue where to start.I have searched a lot and find some of these things.OpenGL,WebGL,XNA and other similar tool can be helpful. please guide me where to start a step by step approach and which platform is better as i have programming background in JAVA. here is an idea what I need to do https://docs.google.com/viewer?a=v&pid=gmail&attid=0.2&thid=13f65486a46a1f67&mt=application/pdf&url=https://mail.google.com/mail/?ui%3D2%26ik%3D49f1f393c6%26view%3Datt%26th%3D13f65486a46a1f67%26attid%3D0.2%26disp%3Dsafe%26realattid%3Df_hi6ylzbv2%26zw&sig=AHIEtbQc8KQNHdprmEnL4UXyD3ox8vlKKQ

    Read the article

  • In Grails, How can I create a domain model to link two of another model?

    - by gerges
    Hey all, I'm currently trying to create a Friendship domain object to link two User objects (with a bit of additional data: createDate, confirmedStatus). My domain model looks as follows class Friendship { User userOne User userTwo Boolean confirmed Date createDate Date lastModifiedDate static belongsTo = [userOne:User , userTwo:User] static constraints = { userOne() userTwo() confirmed() createDate() lastModifiedDate() } } I've also added the following entries to the user class static hasMany = [ friendships:Friendship ] static mappedBy = [ friendships:'userOne' , friendships:'userTwo' ] When I do this, the result is a new friendship created (and viewable through the controller) with both users listed in their respective places. When I view the details of userOne, I see the friedship listed. When I view the details of userTwo, no friendship is listed. This is not the behavior I expected. What am I doing incorrectly? Why can't I see the friendship listed under both users?

    Read the article

  • Best way to model Customer <--> Address

    - by Jen
    Every Customer has a physical address and an optional mailing address. What is your preferred way to model this? Option 1. Customer has foreign key to Address Customer (id, phys_address_id, mail_address_id) Address (id, street, city, etc.) Option 2. Customer has one-to-many relationship to Address, which contains a field to describe the address type Customer (id) Address (id, customer_id, address_type, street, city, etc.) Option 3. Address information is de-normalized and stored in Customer Customer (id, phys_street, phys_city, etc. mail_street, mail_city, etc.) One of my overriding goals is to simplify the object-relational mappings, so I'm leaning towards the first approach. What are your thoughts?

    Read the article

  • EntityDataSource Unable to configure to Entity Model

    - by photo_tom
    I'm doing my first test asp.net3.5 app using EntityDataSource. I've got the basic project built and the Entity model created and compiled. Database is a local sqlexpress one in app_data directory. When I put the <asp:EntityDataSource /> control on the page and try to configure it, I'm getting the message "The list of named connections could not be loaded because the configuration could not be opened". At this point, everything in the project is "auto-created" by Visual Studio 2008sp1. I confused as I cannot find any information on how to correct from this message.

    Read the article

  • in .net, what programming model would be good for prototyping, but then reusable for production (for

    - by Greg
    Hi, In .NET land what would be a good approach for quick prototyping of a concept (i.e. development just on my PC) that could then be extended out to product (users across LAN/WAN), BUT in a fashion that the model/business logic code and data access layer code can be used as is? One thought for example I had as to do: (a) WinForms with business logic and Entity Framework layer to SQL Server Express on my PC, then (b) Go then to ASP.net (using the business logic / data library) with SQL Server/IIS Any comments? Other suggestions?

    Read the article

  • Entity Framework 4.1 auto generate with DbContext when creating ADO.NET Entity Data Model

    - by smudgedlens
    I would like to work with DbContext instead of ObjectContext. I updated EF so now I have the DbContext, but I want to generate my strongly-typed context based on the DbContext and not the ObjectContext. When I add new ADO.NET Entity Data Model, it is still based on the ObjectContext. Is it not possible to have it base off of DbContext in Visual Studio 2010 with EF 4.1? UPDATE: Okay, I followed the directions in this link and was able to generate the DbContext template objects. However, now it is saying there is ambiguity between the template entities and the entities in my .edmx file. How do I resovle this? Do I blow away the ones in the .edmx file?

    Read the article

  • NHibernate: Dynamically swapping a single domain model between multiple physical data models

    - by Nigel
    Hi In this article Ayende describes how to map a single domain model to multiple physical data models. Is it possible to extend this principle such that the mapping can chosen dynamically? So for example, imagine we had an entity that could be written to the same physical schema in three ways depending on its current status, and lets assume that regardless of status each entity had a unique identifier. One solution would be to represent the entity in its different states with three separate classes: one for each mapping. Then the entity could be loaded and in order to change its state the entity could be mapped to a class representing one of its other states and then saved back to the schema, making use of a different mapping. I was wondering if it is at all possible to have the same entity represented by one class that held a status flag (kind of like a discriminator), and any save to the schema would choose the appropriate mapping based on the value of the status flag. Hopefully that made sense! Many thanks.

    Read the article

  • problem using default_scope on a model table

    - by DannyRe
    Hey. In my controller/index action I use the following query: @course_enrollments = current_user.course_enrollments This is what my table looks like. It is referencing a course table. The course table has a colum 'title'. create_table "course_enrollments", :force => true do |t| t.integer "user_id", :null => false t.integer "course_id", :null => false t.datetime "created_at" t.datetime "updated_at" end I want to be able to order my course_enrollments by course in my index view. Furthermore Id like to do a default_scope in my model, like this: default_scope :order => 'title asc' any suggestions? Thx for your time

    Read the article

  • Dynamic Custom Fields for Data Model

    - by Jerry Deng
    I am in the process of creating a dynamic database where user will be able to create resource type where he/she can add custom fields (multiple texts, strings, and files) Each resource type will have the ability to display, import, export its data; I've been thinking about it and here are my approaches. I would love to hear what do you guys think. Ideas: just hashing all the custom data in a data field (pro: writing is easier, con: reading back out may be harder); children fields (the model will have multiple fields of strings, fields of text, and fields for file path); fixed number of custom fields in the same table with a key mapping data hash stored in the same row; Non-SQL approach, but then the problem would be generating/changing models on the fly to work with different custom fields;

    Read the article

  • Constants in Model and View with select option and show view

    - by caplod
    i have a some values ,that i use in my model as constants. class Animal < ActiveRecord::Base LEGS = {:vierbeiner => 4, :zweibeiner => 2 } end in the form (formtastic) for the collection i use: <%= f.input :legs, :as => :select, :collection => Animal::LEGS => but how do i format the show view so instead showing me the number , the key of the hash? in show view i have: <p> <strong>Legs:</strong> <%=h @animal.legs %> </p>

    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

  • Django model class and custom property

    - by dArignac
    Howdy - today a weird problem occured to me: I have a modle class in Django and added a custom property to it that shall not be saved into the database and therefore is not represent in the models structure: class Category(models.Model): groups = models.ManyToManyField(Group) title = defaultdict() Now, when I'm within the shell or writing a test and I do the following: c1 = Category.objects.create() c1.title['de'] = 'german title' print c1.title['de'] # prints "german title" c2 = Category.objects.create() print c2.title['de'] # prints "german title" <-- WTF? It seems that 'title' is kind of global. If I change title to a simple string it works as expected, so it has to do something with the dict? I also tried setting title as a property: title = property(_title) But that did not work, too. So, how can I solve this? Thank you in advance! enter code here

    Read the article

  • Creating seed model from data already in DB

    - by Nick Brown
    Is there a way to convert data in an existing database into objects that can easily be put into a seed method? Essentially I'd like to let some people add lines to my DB via a form and then convert that into an object that I can re-seed the DB anytime I need to make changes. The database itself is created via code-first using the following model: public class Combo { public int Id { get; set; } public string MainPrefix { get; set; } public string MainDescriptor { get; set; } public string MainDish { get; set; } public string Connector { get; set; } public string SecondaryDescriptor { get; set; } public string SecondaryDish { get; set; } }

    Read the article

  • CakePHP: Accessing the controller or model from a view helper

    - by tombazza
    I have a view helper that manages generating thumbnails for images. The images are stored using a unique ID and then linked to a file resource in the database. I am trying to find out if it is possible for the view helper that generates these images to access the model or controller directly, as it is not possible to load the image data at any other point in the controller work flow. I know this is a bit of a hack really, but it is easier than trying to rebuild the entire data management stack above the view.

    Read the article

  • Automatic images translation to 3d model

    - by farrakhov-bulat
    I'm quite interested in automatic images translation to 3d models. Not really for commercial product, but from the point of possible academic research and implementation. What I'd like to achieve is almost transparent for user process of transformation series of images (fewer is better) to 3d model which might be shown in flash/silverlight/javafx or similar. Consider online furniture store with 3d models of all items in stock. Kinda cool to have ability to see the product in 3d before purchasing it. I managed to find a few pieces of software, like insight3d, but it couldn't be used in my case I guess. So, are there any similar projects or tips for me? If it would require to write that piece of software - I'd really love to dig into research on this field.

    Read the article

< Previous Page | 65 66 67 68 69 70 71 72 73 74 75 76  | Next Page >