-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I have a standard ActiveRecord model with the following:
class MyModel < ActiveRecord::Base
custom_method :first_field, :second_field
end
At the moment, that custom_method is picked up by a module sent to ActiveRecord::Base. The functionality basically works, but of course, it attaches itself…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I have three models:
class Book < ActiveRecord::Base
has_many :collections
has_many :users, :through => :collections
end
class User < ActiveRecord::Base
has_many :collections
has_many :books, :through => :collections
end
class Collection < ActiveRecord::Base
belongs_to…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I would like to know if it is possible to get the types (as known by AR - eg in the migration script and database) programmatically (I know the data exists in there somewhere).
For example, I can deal with all the attribute names:
ar.attribute_names.each { |name| puts name }
.attributes just…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I needed to fix the encoding of an ActiveRecord attribute and decided to do it in a before_save hook. And at this point I noticed an unexpected feature. When I wanted to change the value of the attribute, simple using the attribute_name=XY did not work as I expected. Instead of that I needed to use…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
So i am trying to do this
Order.find :all, :conditions => "org = 'test org'"
what ends up firing is
SELECT * FROM `orders` WHERE (org = 'test org')
the whitespace in the argument gets stripped. what am i missing.. im really stumped here. please help!
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hi,
I have two objects with a many-to-many relationship between them, as follows:
public class LeftHandSide
{
public LeftHandSide()
{
Name = String.Empty;
Rights = new HashSet<RightHandSide>();
}
public int Id { get; set; }
public string Name { get; set;…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hello there,
I am trying to use NHibernate with Spring.Net und mySQL 5. However, when setting up the connection and creating the SessionFactoryObject, I get this InvalidCastException:
NHibernate seems to cast MySql.Data.MySqlClient.MySqlConnection to System.Data.Common.DbConnection which causes…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
One of practices advocated by Nhibernate experts is to do all actions in inside a transaction.
In a typical 3 tier web architecture, Nhibernate depedency is limited the data layer.
In such a case is it fine to use
using (var tr = NHibernateSession.Current.BeginTransaction()) {
at the controller…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hello, and first off thanks for your time to look at this.
For a research project I'm working on, I have a somewhat complex design (which I've been given) to persist to a database via NHibernate.
Here's an example of the class hierarchy:
TransitStrategy, TransportationCompany and TransportationLocation…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hello, I have a table with a time column in my SQL Server 2008 database.
The property of the object I'm trying to map to is a TimeSpan.
How can i tell FluentNHibernate to use the TimeAsTimeSpan NHibernate type, so that I don't have cast problems?
>>> More