Storing form methods in a database


#1

Hello all

I am very new to the ruby on rails. I am currently working on a survey
project and I would like to store the survey questions with form
elements in a database. I have been successful with adding the basic
html code needed to display the question, however the rails tags <% %>
are not being executed. Is there a way to force the execution of these
tags when they are passed back from the database?

Thanks to all

Jeffrey Newman

Web D.

Mindshare Interactive Campaigns, L.L.C.

Ph 202.521.4435 / Fax 202.654.0839

www.mindshare.net http://www.mindshare.net/


#2

You should really let people store ruby in a database, there are some
nasty
people out there that would exploit it. I would look at Liquid, from the creator of
Typo.There is a <a
href+“http://leetsoft.com/rails/liquid-installation.mov”>Moview This
seems
like a better solution.

Here To Help
Joey__


#3

I am very new to the ruby on rails. I am currently working on a survey
project and I would like to store the survey questions with form elements in
a database. I have been successful with adding the basic html code needed
to display the question, however the rails tags <% %> are not being
executed. Is there a way to force the execution of these tags when they are
passed back from the database?

Show me the code that’s not working, and what you expect it to do and
I’ll try to give you a hand with it.

You can reach me on IRC as srbaker most of the day (in PST), too.

-Steven


#4

Hi Steve

The problem is I used capture to create a instance variable for the
form or survey question that is stored in the database when I display
the variable <%=@display_question %> Rails renders the html in the
file but for some reason erb is not executing the ruby inside the
delimiters i.e ruby variables that returned form the database or form
methods used to short cut form fields in rails.

Have any ideas how I can get erb to correctly evaluate and execute
the ruby code.

Thanks for your time

Jeff Newman


#5

jeffn05 wrote:

Hi Steve

The problem is I used capture to create a instance variable for the
form or survey question that is stored in the database when I display
the variable <%=@display_question %> Rails renders the html in the
file but for some reason erb is not executing the ruby inside the
delimiters i.e ruby variables that returned form the database or form
methods used to short cut form fields in rails.

Have any ideas how I can get erb to correctly evaluate and execute
the ruby code.

Thanks for your time

Jeff

You need to call a form of the “render” function on this text.


#6

Thanks to All and Steve

I was able to use <%= render :inline => @display_question %>. One
not about doing this make sure the code your are posting in the
database is 100% syntax correct otherwise the proram will throw an
application error.