top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the function of ORM (Object Relationship Model) in Rails?

+2 votes
382 views
What is the function of ORM (Object Relationship Model) in Rails?
posted Oct 26, 2014 by Amit Kumar Pandey

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

ORM stands for Object Relationship Model that models the classes and helps in setting a relationship between the existing models.

=> It allows the classes to be mapped to the table that is present in the database and objects get mapped to the rows in database table.

=> It shows the relationship that exists between the object and frame it using the model to display the output to the users.

=> It keeps the data in the database according to its relationships and performs the functions accordingly.

=> It maps the database in case of any updates and update for the same if the fields are changed or new values are entered.

answer Oct 28, 2014 by Kali Mishra
Similar Questions
+2 votes

I am trying to write a simple calendar app and having troubles with time zones. For as many nice Date and Time helpers, action view and active record sure dont play nice with time zones.

I have an appointment model with the appointment_time attribute which is a datetime. My current issue is editing appointment_time with datetime_select within a form tag.

def appt_time
appointment_time.in_time_zone(time_zone) #this is the appointment owners time zone 
end

This gives a select with the current date and time in UTC, not the appointment date and time. appt_time does get called and returns the correct date and time adjusted for the time zone.

The docs mention nothing about time zones, what is the best way to accomplish this?

+1 vote

I would like to have a form in which some of the fields are linked to model and some fields are not. When I use FORM_FOR tag it binds to a particular model and I cannot create form fields that aren't correspond to one of the column name of the table (Model). Hence what I think is I should use FORM_TAG instead of FORM_FOR so that it contains whatever the form fields it want but one thing I can't find by googling is how can I connect specific fields to a model leaving other fields free of model?

In other words, If I have 5 text_fields in a form how can I link only 3 text_fields to a model and leave other 2 fields free?

...