Hi
My project: Sinatra(modular) - SQLite3 - Sequel on sharing host (Apache,
FastCGI, ruby 1.9.3,)
It uses the existing database tables: 'articles' and 'properties'
Accordingly, models:
class Article < Sequel::Model
end
class Property < Sequel::Model
end
Plan:
Create an new record (Property.new) in 'properties'table: INSERT INTO
`properties` (`name`, `desc`, `tags`) VALUES ('Property_1', 'Color',
'red,black,other')
after, create column in 'articles' with 'property' name: ALTER TABLE
`articles` ADD COLUMN `property_1` text
and create new record (Article.new) in 'articles' table with new
attribute: INSERT INTO `articles` (`property1`, `text`) VALUES ('red',
'loremipsumloremipsum')
route 'post' in Sinatra:
post '/article/submit' do
#Variant 1 Doesnt work
db.schema(:articles, :reload=>true) #return fresh data with new
attribute: [id, text, property_1]
Article.set_dataset :articles
### Check dataset: Article.column #but dataset did not change
### return: [:id, :text]
#Variant 2 Work
Article.send('get_db_schema',:true)
###
### Check dataset: Article.column
### [:id, :text, :property_1]
begin
article = Article.new(params[:article])
rescue => e
puts e # sometimes: "method {name new property}= doesn't exists"
end
if article.save
flash[:success] = "success"
redirect back
else
flash[:error] = "error"
redirect back
end
`end
It always work on the development machine (ruby 1.9.3, rerun, last
Sinatra and Sequel).
But in production on host, sometimes an error: "method {name new
property}= doesn't exists".
After a while you repeat the operation all success.
In case of an error,
'Article.send('get_db_schema',:true)', 'Article.set_dataset :articles
', 'Article.column' return old data, it can be seen in the logs.
What can be linked such a problem?
Thank you in advance
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.