Search Results

Search found 13429 results on 538 pages for 'model reject'.

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

  • Rails Plugin for Multiple Ratings Per Model?

    - by Kevin
    I'm looking to add the capability of rating a model I have under several different categories like "Knowledgeable" "Organized", etc. Is there a plugin that will allow me to do this, and maybe even have a cool x/5 stars graphical representation as well?

    Read the article

  • Override as_json or to_json model class name

    - by Jack
    I'd like to modify the classname when calling to_json on an AR model. i.e. Book.first.to_json #=> "{\"book\":{\"created_at\":\"2010-03-23 Book.first.to_json(:root => 'libro') #=> "{\"libro\":{\"created_at\":\"2010-03-23 Is there an option to do this?

    Read the article

  • Parameterized constructor in view model not working

    - by rajcool111
    I have one small issue. in my view model parameterized constructor is not working. while debugging i observed that default constructor get hit but it never triggers my parameterized constructor. How I can get my parameterized constructor working? public EmployeeRequestViewModel(IEventAggregator eventAggregator, IContextManager contextmanager):this() { _contextmanager = contextmanager; _eventAgg = eventAggregator; _eventAgg.GetEvent<EmployeeEvent>().Subscribe(EventTask); } public EmployeeRequestViewModel() { LoadEmpRequest(); }

    Read the article

  • How to apply query to model if field not filtered

    - by jdog
    I have a range of modules running on generator.yml. In some of those I would like to hide records by default of Status: CLOSED (being the last of a range of Statuses). OF course if the user filters for CLOSED i want to show these records. I thought it would make sense to apply andWhere('status_id=?',Status::CLOSED) in a specific table_method , but how do I access the filters of the module from within the model? Is there a better way to do this?

    Read the article

  • Advanced Model Binding vs 2010

    - by user281180
    Can I have an example of advanced model binding using ajaxpost? I have two classes Person and Test as follows: public class person{ public ArrayList Name = new ArrayList(); public Test []test {get;set;} } public class Test { public int ID{get;set;} public int mark{get;set;} } My Controller could be [HttpPost] public EmptyResult CaseTest(Person person) { return new EmptyResult(); } How do I post the values from the view?

    Read the article

  • Validate dependent model validation and show error message.

    - by piemesons
    Just taking a simple example. We have a question on stackoverflow and while posting a question we want to validate title_of_question, description_of_question that they should be present. Now we have a another model tag having habtm relationshio with question model. How to validate that while saving the question. Means question must have some tags. here the code:-- Models:-- class Question < ActiveRecord::Base belongs_to :user has_and_belongs_to_many :tags has_many :comments, :as => :commentable has_many :answers, :dependent => :destroy validates_presence_of :title, :content, :user_id end class Tag < ActiveRecord::Base has_and_belongs_to_many :questions validates_presence_of :tag end Form for entering question and tag <div class="form"> <% form_for :question ,@question, :url => {:action => "create" } do |f| %> <fieldset> <%= f.error_messages %> <legend>Post a question</legend> <div> <%= f.label :title %>: <%= f.text_field :title, :size => 100 %> </div> <div> <%= f.label :content ,'Question' %>: <%= f.text_area :content, :rows => 10, :cols => 100 %> </div> <div> <%= label_tag 'tags' %>: <%= text_field_tag 'tag' ,'',:size=> 60 %> add multiple tag using comma </div> <div> <%= submit_tag "Post question" %> </div> </fieldset> <% end %> </div> From Controller.. (Right now question will be saved without validating tag) def create @question = Question.new(params[:question]) @question.user_id=session[:user_id] if @question.save flash[:notice] = "Question has been posted." redirect_to question_index_path else render :action => "new" end end questions_tags table has been created. One approach is creating a virtual column using attribute accessors. another approach is validate associated. right now assuming new tags can be created.(but not duplicate).

    Read the article

  • Rails model without database

    - by FlipFlop
    I want to create a Rails (2.1 and 2.2) model with ActiveRecord validations, but without a database table. What is the most widely used approach? I've found some plugins that claim to offer this functionality, but many of them don't appear to be widely used or maintained. What does the community recommend I do? Right now I am leaning toward coming up with my own solution based on this blog post.

    Read the article

  • Howoto get id of new record after model.save

    - by tonymarschall
    I have a model with the following db structure: mysql> describe units; +------------+----------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+----------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(128) | NO | | NULL | | | created_at | datetime | NO | | NULL | | | updated_at | datetime | NO | | NULL | | +------------+----------+------+-----+---------+----------------+ 7 rows in set (0.00 sec) After creating a new record an saving i can not get the id of the record. 1.9.3p194 :001 > unit = Unit.new(:name => 'test') => #<Unit id: nil, name: "test", created_at: nil, updated_at: nil> 1.9.3p194 :002 > unit.save (0.2ms) BEGIN SQL (0.3ms) INSERT INTO `units` (`created_at`, `name`, `updated_at`) VALUES ('2012-08-31 23:48:12', 'test', '2012-08-31 23:48:12') (144.6ms) COMMIT => true 1.9.3p194 :003 > unit.inspect => "#<Unit id: nil, name: \"test\", created_at: \"2012-08-31 23:48:12\", updated_at: \"2012-08-31 23:48:12\">" # unit.rb class Unit < ActiveRecord::Base attr_accessible :name end # migration class CreateUnits < ActiveRecord::Migration def change create_table :units do |t| t.string :name, :null => false t.timestamps end end end Tried this with other models and have the same result (no id). Data is definitily saved and i can get data with Unit.last Another try with Foo.id = nil # /var/www# rails g model Foo name:string invoke active_record create db/migrate/20120904030554_create_foos.rb create app/models/foo.rb invoke test_unit create test/unit/foo_test.rb create test/fixtures/foos.yml # /var/www# rake db:migrate == CreateFoos: migrating ===================================================== -- create_table(:foos) -> 0.3451s == CreateFoos: migrated (0.3452s) ============================================ # /var/www# rails c Loading development environment (Rails 3.2.8) 1.9.3p194 :001 > foo = Foo.new(:name => 'bar') => #<Foo id: nil, name: "bar", created_at: nil, updated_at: nil> 1.9.3p194 :002 > foo.save (0.2ms) BEGIN SQL (0.4ms) INSERT INTO `foos` (`created_at`, `name`, `updated_at`) VALUES ('2012-09-04 03:06:26', 'bar', '2012-09-04 03:06:26') (103.2ms) COMMIT => true 1.9.3p194 :003 > foo.inspect => "#<Foo id: nil, name: \"bar\", created_at: \"2012-09-04 03:06:26\", updated_at: \"2012-09-04 03:06:26\">" 1.9.3p194 :004 > Foo.last Foo Load (0.5ms) SELECT `foos`.* FROM `foos` ORDER BY `foos`.`id` DESC LIMIT 1 => #<Foo id: 1, name: "bar", created_at: "2012-09-04 03:06:26", updated_at: "2012-09-04 03:06:26">

    Read the article

  • In App Purchase with Subscription Model

    - by Evangelist
    Does anyone have any idea of a service provider that provides In App Purchase with subscription model. I checked Urban Airship which has solution built around non-consumable approach and iLime is not available yet. Any pointers in the right direction would be appreciated.

    Read the article

  • Google App Engine: Update model definitons?

    - by Rosarch
    I recently updated one of my models by adding a db.ListProperty(): class DependencyArcTail(db.Model): courses = db.ListProperty(db.Key) ''' newly added ''' forwardLinks = db.ListProperty(db.Key) However, I can't seem to get this to be reflected in the SDK dashboard. I cleared the datastore and reloaded it. Then I ran the procedures that create the DependencyArcTail objects. However, forwardLinks still doesn't show up as an attribute in the SDK dashboard. What's happening?

    Read the article

  • Change|Assign parent for the Model instance on Google App Engine Datastore

    - by Vladimir Prudnikov
    Is it possible to change or assign new parent to the Model instance that already in datastore? For example I need something like this task = db.get(db.Key(task_key)) project = db.get(db.Key(project_key)) task.parent = project task.put() but it doesn't works this way because task.parent is built-in method. I was thinking about creating a new Key instance for the task but there is no way to change key as well. Any thoughts?

    Read the article

  • Data Annotations validation Built into model

    - by Josh
    I want to build an object model that automatically wires in validation when I attempt to save an object. I am using DataAnnotations for my validation, and it all works well, but I think my inheritance is whacked. I am looking here for some guidance on a better way to wire in my validation. So, to build in validation I have this interface public interface IValidatable { bool IsValid { get; } ValidationResponse ValidationResults { get; } void Validate(); } Then, I have a base class that all my objects inherit from. I did a class because I wanted to wire in the validation calls automatically. The issue is that the validation has to know the type of the class is it validating. So I use Generics like so. public class CoreObjectBase<T> : IValidatable where T : CoreObjectBase<T> { #region IValidatable Members public virtual bool IsValid { get { // First, check rules that always apply to this type var result = new Validator<T>().Validate((T)this); // return false if any violations occurred return !result.HasViolations; } } public virtual ValidationResponse ValidationResults { get { var result = new Validator<T>().Validate((T)this); return result; } } public virtual void Validate() { // First, check rules that always apply to this type var result = new Validator<T>().Validate((T)this); // throw error if any violations were detected if (result.HasViolations) throw new RulesException(result.Errors); } #endregion } So, I have this circular inheritance statement. My classes look like this then: public class MyClass : CoreObjectBase<MyClass> { } But the problem occurs when I have a more complicated model. Because I can only inherit from one class, when I have a situation where inheritance makes sense I believe the child classes won't have validation on their properties. public class Parent : CoreObjectBase<Parent> { //properties validated } public class Child : Parent { //properties not validated? } I haven't really tested the validation in these cases yet, but I am pretty sure that anything in child with a data annotation on it will not be automatically validated when I call Child.Validate(); due to the way the inheritance is configured. Is there a better way to do this?

    Read the article

  • Microsoft .NET security model

    - by Thomas
    Hi all, I am looking for informations about the security model of Microsoft .NET If you could explain me how it is design, or give me links to understand it, it would be very kind of you ! Thanks.

    Read the article

  • Database model for storing expressions and their occurrence in text

    - by lisak
    Hey, I'm doing a statistical research application. I need to store words according to 2 initial letters which is 676 combinations and each word has its number of occurrences (minimal, maximal, average) in text. I'm not sure how the model/schema should look like. There will be a lot of checking whether the keyword was already persisted. I appreciate your suggestions. Edit: I'll be using either mysql or postgresql + spring templates

    Read the article

  • Rails - Accessing Model Attributes in Forms

    - by stringo0
    Hi, How do I access a model's parent's attribute in a form? For example, for the following form for answer, I want to access answer.question.text and use that for the question - how do I do this? Thanks! <% form_for :answers do |ans| %> <%= ans.label :question, "Question" %> <%= ans.text_field :value %>

    Read the article

  • Django m2m adding field in the secondary table

    - by dana
    I have a model in wich i'm using m2m Django ORM feature, in order to create an aditional table to hold my 'classrom members'. My problem is: the membership to a classroom must be accepted by the invited one, so i need a boolean field :1=accepted, 0=refused/unseen yet. How can i include this boolean variable in the aditionally generated classroom_membership (and NOT in the primary created Classroom table)? class Classroom(models.Model): user = models.ForeignKey(User, related_name = 'classroom_creator') classname = models.CharField(max_length=140, unique = True) date = models.DateTimeField(auto_now=True) open_class = models.BooleanField(default=True) #domain = models.EnumField() members = models.ManyToManyField(User,related_name="list of invited members") Thanks in advance!!

    Read the article

  • How can I get model names from inside my app?

    - by Cameron
    I have a bunch of models in a sub-directory that inherit from a model in the models root directory. I want to be able to set a class variable in another model that lists each inherited model class. i.e @@groups = sub_models.map do { |model| model.class.to_s } Not sure how to get at this info though...

    Read the article

  • making query from different related tables using codeigniter

    - by fatemeh karam
    I'm using codeigniter as i mentioned this is a part of my view code foreach($projects_query as $row)// $row indicates the projects { ?> <tr><td><h3><button type="submit" class="button red-gradient glossy" name = "project_click" > <?php echo $row->txtTaskName; ?></button></h3></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <?php foreach($tasks_query as $row2) { // if( $row->txtTaskName == "TestProject") if($row->intTaskID == $row2->intInside)// intInside indicades that the current task($row2) is the subset of which task (system , subsystem or project) { if($row2->intSummary == 0)//if the task(the system) is an executable task & doesn't have any subtask: { $query_team_user_id = $this->admin_in_out_model->get_user_team_task_query($row2->intTaskID);//runs the function and generates a query from tbl_userteamtask where intTaskID equals to the selected row's intTaskID foreach($query_team_user_id as $row_teamid) { $query_teamname = $this->admin_in_out_model->get_team_name($row_teamid->intTeamID); $query_fn_ln = $this->admin_in_out_model->get_fn_ln_from_userid($row_teamid->intUserID); foreach($query_teamname as $row_teamname) {?> <tr><td></td><td></td><td><h4> <?php echo $row2->txtTaskName;?></h4></td> <td><b><font color='#F33558'><?php echo $row_teamname->txtTeamName;?></font></b></td> <?php } foreach($query_fn_ln as $row_f_l_name) {?> <td> <?php echo $row_f_l_name->txtFirstname." ".$row_f_l_name->txtLastname;?></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td> <?php }?> </tr> <?php } } else{ ?> <tr><td></td><td></td><td><h4> <?php echo $row2->txtTaskName;?></h4></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><?php } foreach($tasks_query as $row_subsystems) { if($row_subsystems->intInside == $row2->intTaskID )//if the task is the subtask of a system(it means the task is a subsystem) { if($row_subsystems->intSummary == 0)//if the task is an executable task & doesn't have any subtask: { $query_team_user_id = $this->admin_in_out_model->get_user_team_task_query($row_subsystems->intTaskID); foreach($query_team_user_id as $row_teamid) {?> <tr><?php $query_teamname = $this->admin_in_out_model->get_team_name($row_teamid->intTeamID); $query_fn_ln = $this->admin_in_out_model->get_fn_ln_from_userid($row_teamid->intUserID); foreach($query_teamname as $row_teamname) {?> <td></td><td></td><td><h5><?php echo $row_subsystems->txtTaskName?></h5><br/></td> <td><b><font color='#F33558'><?php echo $row_teamname->txtTeamName;?></font></b></td><?php } foreach($query_fn_ln as $row_f_l_name) {?> <td><?php echo $row_f_l_name->txtFirstname." ".$row_f_l_name->txtLastname;?></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><?php }?> </tr><?php } } else{ ?><tr><td></td><td></td><td><h5><?php echo $row_subsystems->txtTaskName?></h5></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><?php } foreach($tasks_query as $row_tasks) { if($row_tasks->intInside == $row_subsystems->intTaskID )//if the task is the subtask of a subsystem { if($row_tasks->intSummary == 0)//if the task is an executable task & doesn't have any subtask: { $query_team_user_id = $this->admin_in_out_model->get_user_team_task_query($row_tasks->intTaskID); foreach($query_team_user_id as $row_teamid) {?> <tr><?php $query_teamname = $this->admin_in_out_model->get_team_name($row_teamid->intTeamID); $query_fn_ln = $this->admin_in_out_model->get_fn_ln_from_userid($row_teamid->intUserID); foreach($query_teamname as $row_teamname) {?> <td></td><td></td><td><b><?php echo $row_tasks->txtTaskName;?></b></td> <td><b><font color='#F33558'><?php echo $row_teamname->txtTeamName;?></font></b></td><?php } foreach($query_fn_ln as $row_f_l_name) {?> <td><?php echo $row_f_l_name->txtFirstname." ".$row_f_l_name->txtLastname;?></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><?php }?> </tr><?php } } } } } } } } }?> and in controller i have $projects_query = $this->admin_in_out_model->get_projects(); $tasks_query = $this->admin_in_out_model->get_systems(); $userteamtask = $this->admin_in_out_model->get_user_team_task(); $data['tasks_query'] = $tasks_query; $data['projects_query'] = $projects_query; $this->load->view('project_view',$data); but as you see I'm calling my model functions within the view how can i do something else to do this i mean not calling my model function in my view I have to add that, my model function have parameters these are the model functions: function get_projects() { $this -> db -> select('*'); $this -> db -> from('tbl_task'); $this -> db -> where('intInside','0'); $query = $this->db->get(); return $query->result(); } function get_systems() { $this -> db -> select('*'); $this -> db -> from('tbl_task '); $this -> db -> where('intInside <> ','0'); $query = $this->db->get(); return $query->result(); } function get_user_team_task_query($task_id)//gets information from tbl_userteamtask where the field intTaskID is equal to $task_id { $this -> db -> select('*'); $this -> db -> from('tbl_userteamtask'); $this -> db -> where('intTaskID',$task_id); $query_teamid = $this->db->get(); return $query_teamid->result(); } function get_user_team_task()//gets information from tbl_userteamtask where the field intTaskID is equal to $task_id { $this -> db -> select('*'); $this -> db -> from('tbl_userteamtask'); // $this -> db -> where('intTaskID',$task_id); $query_teamid = $this->db->get(); return $query_teamid->result(); } function get_team_name($query_teamid) { $this -> db -> select('*'); $this -> db -> from('tbl_team'); $this -> db -> where('intTeamID',$query_teamid); $query_teamname = $this->db->get(); return $query_teamname->result(); } function get_user_name($query_userid) { $this -> db -> select('*'); $this -> db -> from('tbl_user'); $this -> db -> where('intUserID',$query_userid); $query_username = $this->db->get(); return $query_username->result(); } function get_fn_ln_from_userid($selected_id) { $this -> db -> select('tbl_user.intUserID, tbl_user.intPersonID,tbl_person.intPersonID,tbl_person.txtFirstname, tbl_person.txtLastname'); $this -> db -> from('tbl_user , tbl_person'); $where = "tbl_user.intPersonID = tbl_person.intPersonID "; $this -> db -> where($where); $this -> db -> where('tbl_user.intUserID', $selected_id); $query = $this -> db -> get();//makes query from DB return $query->result(); } do I have to use subquery ? is this true? i mean can i do this? foreach( $data as $key => $each ) { $data[$key]['team_id'] = $this->get_user_team_task_query( $each['intTaskID'] ); foreach($data[$key]['team_id'] as $key_teamname => $each) { $data[$key_teamname]['team_name'] = $this->get_team_name( $each['intTeamID'] ); } } the model code: foreach( $data as $key => $each ) { $data[$key]['intTaskID'] = $each['intTaskID']; $data[$key]['team_id'] = $this->get_user_team_task_query( $each['intTaskID'] ); foreach($data[$key]['team_id'] as $key => $each) { $data[$key]['team_name'] = $this->get_team_name( $each['intTeamID'] ); #fetching of the teamname and saving in the array $data[$key]['user_name'] = $this->get_fn_ln_from_userid( $each['intUserID'] ); foreach($data[$key]['user_name'] as $key => $each) { $data[$key]['first_name'] = $each['txtFirstname'] ; $data[$key]['last_name'] = $each['txtLastname'] ; } $data[$key]['first_name'] = $data[$key]['first_name']; $data[$key]['last_name'] = $data[$key]['last_name']; } }

    Read the article

  • cakePHP, multiple hasOne in a single model

    - by jason
    say you have 3 models : user, hair_color, and eye_color user hasOne hair_color user also hasOne eye_color however var $hasOne = 'hair_color'; var $hasOne = 'eye_color'; obviously wont work. So how do you implement many hasOne relationships in a single model? I assume the answer is in the cookbook, Im going over that area now, I suspect it has something to do with passing an array to $hasOne, but no example of doing this.

    Read the article

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