Sinatra and Datamapper - inserting data to a one to many relationship table?

I believe that through => Resource is only needed if you are doing a many-to-many relationship. A one-to-many, which I think is what you want, does not require that. Check out the post and comment relationship shown on the associations page EDIT for comment: If I were you, I would name my form fields normally and construct the database object manually, for example: form action="/create" method="post"> Article Title Article Body Url params:title, :body => params:body ) @url = url.

New( url_01 => params:url ) @article. Url = @url if @article. Save redirect "/articles" else redirect "/articles/new" end end.

I believe that , through => Resource is only needed if you are doing a many-to-many relationship. A one-to-many, which I think is what you want, does not require that. Check out the post and comment relationship shown on the associations page.

EDIT for comment: If I were you, I would name my form fields normally and construct the database object manually, for example: Article Title Article Body Url and then: post '/create' do @article = Article. New( :title => params:title, :body => params:body ) @url = url. New( url_01 => params:url ) @article.

Url = @url if @article. Save redirect "/articles" else redirect "/articles/new" end end.

Does not work, the input does not get saved into database. – little. Programmer Jul 18 '10 at 17:52 In the above example, he just has "url" as the field in the html form.

If you are showing all three, then you would need to update the url. New constructor with all three from the html form. – Ian Jul 19 '10 at 14:39.

I would want to store the urls in a different table. Therefore in my form, i've a field for the urls. However they are not working, only the article fields get entered into the database.

How should I specify them? Could any kind soul help me out with this?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions