Anyway to make a field conditionally required based on whether or not another field in the same form has been filled out?
If field1 has no data, but field2 does
form is valid.
If field1 has no data and field2 has no data
form is invalid
Not looking for any javascript solutions. I feel as it should be solved with django for...
In my database, OptionSets are associated with other OptionSets. If I was joining two separate tables I would create a simple join table. However, Rails likes to have its foreign keys named <singular_table_name>_id, i.e. optionset_id. However, if I am joining the table with itself I obviously cannot give the two tables the same name. ...
I'm having problems with my rails custom validations.
def validates_hsp_program(*attr_names)
options = attr_names.extract_options!
regex = '^('
err = ''
$CetConfig.program.each do |key, val|
regex << val.to_s << '|'
err << $CetConfig.program_prefix + " " + val.to_s + ", "
end
regex.chomp!('|')
...
Hi, whats the best free entity relationship modelling tool?
I have an sql server 2008 database that I want to be modelled out with fields and foreign key contraints and I dont particulary like the one which is built into SQL Management studio.
...
I want to put some model level validation on the following table:
create_table :audios do |t|
t.integer :library_id, :null => false
t.string :file, :null => false, :limit => 2048
t.string :name, :limit => 512
t.timestamps
end
Does this mean, that my model, which (so far) looks like:
class Audio < ActiveRecord::Base
belongs_...
I have a few models, all with appropriately named model files.
$this->Property->PropertyImage->Image->read();
All linked accordingly. Problem is, the recursive model is not able to attach to all the relationships and for some reason is returning AppModel data type when i do a var_dump on $this->PropertyImage. When i do a var_dump($thi...
I have been thinking and learning a lot about forms lately trying to add advanced extensions to the Spree ECommerce Platform: Subscriptions, Events, Donations, and all kinds of Surveys.
Every example I have ever encountered (in blogs, in the docs, in screencasts, in source code, etc.) make forms out of Models, but they never go to anyth...
So I've got this class where I have to make a simple game in OpenGL.
I want to make space invanders (basically).
So how in the world should I make anything appear on my screen that looks decent at all? :(
I found some code, finally, that let me import a 3DS object. It was sweet I thought and went and put it in a class to make it a littl...
I have a User model with a number of very similar properties that I want to list without typing each on in individually.
So, rather than:
"eye color: #{@user.his_eye_color}"
"hair color: #{@user.his_hair_color}"
"height: #{@user.his_height}"
"weight: #{@user.his_weight}"
...
"eye color: #{@user.her_eye_color}"
"hair color: #{@user.her...
Hello everybody, I am new to both Android and Stack Overflow. I have started developing and Android App and I am wondering two things:
1) Is it possible to parametrize a TextView? Lets say I want to render a text message which states something like: "The user age is 38". Lets suppose that the user age is the result of an algorithm. Usin...
I have Users which can be either TypeS, TypeC, or TypeA. I have models for each of these types to store additional information. Now, in the Users table, should I have
3 nullable foreign-key fields to designate which type they are
2 fields, 1 with the name of the type and 1 with the foreign key
1 field designating the type with the for...
I'm working with Ruby on Rails, but this question I think is broader than that and applies to database design generally.
When is it a good idea to split a single model up into multiple tables? For example, assume I have a User model, and the number of fields in the model is really starting to add up. For example, the User can enter hi...
I'm new to unit-testing, so this is maybe a little dumb question.
Imagine, we have a simple model method.
public function get_all_users($uid = false, $params = array()){
$users = array();
if(empty($uid) && empty($params)){return $users;}
$this->db->from('users u');
if($uid){
$this->db->where('u.id',(int)$id);
...
I have a view definition that (attempts to) outputs a model as a table. This is what I have so far:
def output_table(request):
output = My_Model()
return render_to_response('outputtable.html', {'output': output})
Here's the HTML for outputtable.html:
<html>
<table>
{{ output.as_table }}
</table>
</html>
What am I doing ...
I'm new to CakePHP, and still figuring out the basics. Right now I'm a bit mystified by the process to get one or more fields from a model (from inside another linked model).
So far, I have this:
$this->user->id = 123;
$this->User->read();
$field1 = $this->User->data['User']['field1'];
$field2 = $this->User->data['User']['field2'];
W...
What is the best way to handle this:
class Option {
int id;
string name;
}
class QuoteItem
{
IList<Option> options;
}
class QuoteViewModel {
IList<Option> allOptions;
QuoteItem quoteItem;
}
Basically, I have all the available options in allOptions. I want to have a checkbox that puts another Option (even if it...
Looking for some guidance on the best way to implement this scenario:
I have an items table (of products) and want to support the ability to cross-sell / up-sell / complement items. So there is an item-to-item(s) relationship here. In this join table I need to include additional attributes beyond the keys such as the sales_relation betw...
My debug value is set to 2, and it's displaying all the queries,
except the one I need.
I have an Items Controller method that is calling this User Model
(Item belongsTo User):
function add_basic($email, $password)
{
$this->create();
$this->set(array(
...
Techniques: ORM, Doctrine 1.1.6, KohanaPHP
With Doctrine 1.1.6. How do I spread a model over different tables?
Detailed situation:
I have the class Entity which contains an ID, login and password and has one emailaddress, many addresses and some other relations. I have two other classes, Company and Person, which extend Entity. I want...
I have the hair-brained idea of grouping models from different existing apps into one big new shiny app. There's not a super important reason I need to do this, but it would be nice to consolidate all of the code in one subdirectory and it would improve the site to group all the models together in the admin_index under the same module he...