Hello,
Is there any way to alter my Model properties from a javascript function inside a view?
Specifically, I have an edit view and need to access a string property value with
function SomeJSFunction() {
var somevar = '<%=Model.Property %>';
...
then do some changes on somevar and set the model property to the changed s...
I this model:
class Bunny < ActiveRecord::Base
attr_accessor :number
validates_presence_of :number
validates_numericality_of :number
end
Whenever I submit a form to create this model I get the following error:
undefined method `number_before_type_cast' for #<Bunny:0x103624338>
...
Using for example
class model(models.Model)
....
def my_custom_method(self, *args, **kwargs):
#do something
When I try to call this method during pre_save, save, post_save etc, Python raises a TypeError; unbound method.
How can one add custom model methods which can be executed in the same way like model.objects.get()...
I may be approaching this from the wrong angle entirely, but hopefully someone will know a way of acheiving what I'm after.
I reference a web service, which returns an ErrorInfo object. I add each returned error to the ModelState as a ModelError:
foreach(ErrorInfo error in serviceResponse)
ModelState.AddModelError(error.AssociatedF...
Hi,
I am trying to build a simple username-password-role based security object model for my application. The requirement is that user will enter using username and password and he/she will have enable and disable access to the part of the system depending upon whatever role they fall into. which I think is fairly simple idea.
Now here...
I am working on a Django project where a Thing would have a unique 10 digit Key, in addition to the standard auto incrementing ID integerfield. I use a simple random number function to create it. [I'm sure there's a better way to do this too]
When a Thing is created, a 10 digit Key is created. I use the .validate_unique() to check th...
When I save data in one model, I'd like to create some data in another model and save that too. Because I can't do this using beforeSave(), I eventually decided to use afterSave() to create new data items in my second model. I'm not writing a blog application, but to use the blog analogy it's equivalent to automatically creating a series...
I'm fairly new to rails, working on a Rails 3 app with a Profile model for users.
In the profile Model I'd like to have a "name" entry, and I'd like to be able to access logical variations of it using simple syntax like:
user.profile.name = "John Doe"
user.profile.name.first = "John"
user.profile.name.last = "Doe"
Is this possible, o...
Hi there,
I know the following model code is not correct: as models get loaded only on server boot, time "constants" are loaded at that time only, too.
class Article < ActiveRecord::Base
def expiring?
if (self.enddate - Time.now) <= 1.day
true
else
false
end
end
end
What do I have to correct how, so that...
If a model's field is a choice or foreign key, the widget on the page is a select input or radios if you specify that. Django places "---------" in the first item as an unselected value. How can I override it or even remove it? I remember reading the way to do it but can't find it any more.
...
Hi, I'm currently developing an application whereby a user clicks a button and they're offered up a new page of content, and was wondering how I would go about hiding or skipping past those that the user has already interacted with (a separate table stores the post_id and user_id for each view).
I currently use this code in the model fo...
Hey guys,
I have a bunch of digital 3d models (in whatever format, I can probably accommodate the conversion) and all I'm trying to do is to find a flash 3d viewer that dynamically gets a 3d model and then allows the user to do things like pan, zoom, and move around in the model. These are specifically models of units and properties, s...
Hi,
I need to make an app available for just one particular device model (or alternatively for just tablets) on the Android Market.
Is that possible?
Thanks for any hints.
...
I have two tables, tasks and projects. And every task has a project (and every project can have N tasks).
When adding or editing a task, projects are displayed as dropdown as it should, but dropdown is ordered by ID (or no ordering at all). Because i start to have plenty of projects, is there a way to get projects in a dropdown in alpha...
Hi, I'm creating an application that'll display a random picture based upon a defined letter in a word.
Images are attached to a Pictures model (containing another "letter" field) using Paperclip, and will be iterated through in an each block.
How would I go about passing the letter back from the each block to the model for random sele...
I have three Models (and growing): ContactEmail, ContactCall, ContactPostalcard
I want to cycle through the three of them to go through a pretty lengthy loop.
A sample would would be the following:
import_event = ContactEmail.sugarcrm_is(false) #using searchlogic gem
The second loop would be:
import_event = ContactCall.sugarcrm_is(...
i have a tweet table that stores tweets and its replies like this
tweet(id, parent_id, tweet_message, time)
where parent_id is a self id if its a tweet and is of parent id if its a reply. how to do a find to pull out tweets where id = parent_id
example:
tweet(1, 1, 'My name is Harsha', 'time') parent_id = id since its a tweet and...
In a Doctrine Record object, I can add the following method to validate data:
protected function validate()
{
if (empty($this->first_name) && empty($this->last_name) && empty($this->company)) {
$this->getErrorStack()->add('company', 'You must fill in at least one of the following: First Name, Last Name, Company');
}
}
...
I have a question regarding Model Binding in MVC
Say I have a simple POCO like below.
public class Person
{
public Title Title { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public bool LeadPassenger { get; set; }
}
I have a controller that passes a collection of Persons to a ...
Hello
I'm currently making an IDE for the Java platform. This IDE for education purposes only.I'm working of the documentation and in the analysis phase.
Right now I'm at the stage of making the domain model for my project and I'm confused what to as to how the domain model figure would look like.
The IDE will feature
open/save
creat...