Hi,
I am New to rails.I have tried this one good examples through out the site.
But, Some Images are not cropping and default size is cropping an Image saving with defaults.
Plz Help?
Thanks for this Screen casts
As I understand it, just the paid service is shutting down...but you can still use the product the paid service is based on copycopter-server but you have to host it yourself now, that's all.
How would I configure multiple websites on the same box? I know they would each be in a different directory by application name but how would I redirect using domain name. I know I would have to use apache virtual hosts but with Nginx I'm not sure.
Would it be better to have one IP address or multiple (looks like $1/IP on Linode).
You could check if the model exists for the current locale (I think there is a method for that - would have to look it up) and if not redirect to the existing locale. Or add a text in that case saying something like "This Article doesn't exist in your language". And then you could link to all available language versions of that article. Clicking on one of the links, will change the app to the selected locale. That is also better in terms of usability compared to fallbacks, as it's not nice to have for example a russian article appear within a layout with english texts.
It should probably be noted that at the moment there is a small glitch (regarding accessors / mass assignment) that prevents Globalize3 from working fully and seamlessly with rails 3.2.3. It will be fixed very soon, though!
Nice advice to put it in a initializer.
I also came across this solution a time ago. This works for some cases.
When you have a large website 10 or more locales its not handy to define a fallback for each locale. The point is you have to define the fallbacks static.
I am using an Article to explain my problem but a more suitable case is when you have an Festival. An Festival is held in a Country and has a language that is the base language for the Festival. The Festival is held in England so the organisation enters the data in the English language. The organisation decides also to translate the translate the website in the WK language. Now a German guys enters the website, what i dont want is that the website shows the Festival in the next best fallback language but the language its originally created with. Because a Festival can also be entered in the WK language(original) and English language (translation) then a German user needs to see the Festival information in WK.
I was having a great challenge with Globalize3 regarding translating models on a website. Globalize3 relies on models created by a base locale set by I18n.locale or config.i18n.default_locale. Now lets have this situation when video above has three locales, WK, DE and EN (EN set as default). I have my fallback set to the en locale.
When I enter articles in english all goes fine, all the entries are now English for all locales. But for example when i try to make an article in WK language only, Globalize wont fall back to that language when the user browses the English or German language. For example when I view the page in German it still falls back to the English locale which is not set. Any suggestions how to fall back to the locale in which the Model is originally created when other locales are not set?
So my goal was; when a Article is created in a locale (WK) other then the default_locale (EN), the application needs to show that locale (WK) in the article as fallback locale. Even when i enter a translation for the default locale (EN) and the user requests the page in German (DE) the article is shown in the (WK) locale.
What i did is create an base_locale attribute to the Article model and tried overriding the read_attributes globalize uses. Here is some code
ruby
classLanguage < ActiveRecord::Base
attr_accessible :locale, :nameendclassArticle < ActiveRecord::Base
translates :title, :description, :fallbacks_for_empty_translations => true
attr_accessible :title, :description:base_locale_sym
belongs_to :base_locale, :class_name => "Language", :foreign_key => "base_locale_id"
before_save :set_base_locale_cachedefset_base_locale_cacheifself.base_locale_id_changed?
unlessself.base_locale.blank?
#sets the base locale cache for the created Article#i dont want to query Article.base_locale each time...self.base_locale_sym = Language.find(self.base_locale_id).locale
elseself.base_locale_sym = ""endendenddefread_attribute(name, options = {})
#when the translated_locales does not include the i18n.locale try to show the model in the locale in which the Article was first created.unlessself.translated_locales.include? I18n.locale.to_sym
#merge the options hash
options.merge(:locale => self.base_locale_sym)
endsuper(name,options)
endend
This idea worked quite fine, but i had really issues with updating and generating models. Maybe someone got a better idea?
I couldn't figure out this puzzle so i stopped it 3 months ago. Since this railscast is about globalize, I thought maybe we can solve it..
If you don't have a lot of languages but just two or three or so, you could keep things simpler with multiple columns in the same table. We wrote Traco for that recently, inspired by an earlier plugin called translatable_columns.
i don't really understood, how can deploy:setup successfully completed?
Because we can't create symlinks to non existing files.
Only after deploy:cold we get current folder with nginx.conf and unicorn_init.sh files.
ruby
** [out :: 172.17.11.10] creating symbolic link `/etc/nginx/sites-enabled/abc' to `/home/rails/apps/abc/current/config/nginx.conf'
** [out :: 172.17.11.10] : No such file or directory
At 9:49, my response.responseText contained {"name":["can't be blank"]}
and not {"errors": {"name":["can't be blank"]}} (i.e. there was no "errors" key).
So when parsing the messages within entries/index.js.coffee#handleError method, I did
coffee
errors=$.parseJSON(response.responseText)
instead of
coffee
errors=$.parseJSON(response.responseText).errors
I have rails 3.1.2, and my web browser is Chrome 16.0.912.77.
No need for YML files, full support for language context rules and language cases. Uses crowd-sourced or professional translator provided translations.
Here is what some of the translations would look like. t method is replaced with tr.
<%= tr("Hello World!") %>
<%= tr("Name:", "User name label") %>
uses description to provide context for the label
<%= tr("You have {count|| message} in your mailbox.", nil, {count: 5}) %>
will use numeric rules and inflectors to provide the right form for message/messages
<%= tr("{actor} sent {target::dat} a message.", nil, {actor:user1, target:user2}) %>
will use gender of {actor} user to provide the right form for word "sent" and apply Dative language case to the name of target user token.
similar to the above example, but also adds a decoration token around the number of messages. Here is an example in English:
Michael sent Anna 5 messages.
In Russian this would need 9 translations based on the gender of actor (male, female, unknown) as well as value of count: 3 cases as well. It can translate names as well, if you so desire.
Михаил послал Анне 5 сообщений.
The technology is very powerful and has been used by Geni and Yammer and a few other companies and is now open sourced.
Hey Alan,
You were correct. Originally I followed your instructions and added a "require tree ." in the last line. But for whatever reason, I left the original "require tree ." in the line above. So the problem was still there (and Stuart spotted that in his comment below).
You only need it once, at the bottom of the file.
Root level files get required first, if you use require_tree.
So raffler.js.coffee is getting processed before all the other files, such as the routers etc.
p.s. I'm trying this on a windows machine.
It looks to be a known issue: https://github.com/sstephenson/eco/issues/29
I'm looking into alternatives to eco on windows
Thanks for that I was missing the require => 'bcrypt', this solved the problem for me too.
I'm having the same issue.
Did you manage to fix it?
Hi,
I am New to rails.I have tried this one good examples through out the site.
But, Some Images are not cropping and default size is cropping an Image saving with defaults.
Plz Help?
Thanks for this Screen casts
Got it. I had to customize nginx.conf
I used this with my "main" app
listen 80 default deferred;
Do you see any ways to improve this?
You are welcome ;)
You are welcome ;)
As I understand it, just the paid service is shutting down...but you can still use the product the paid service is based on copycopter-server but you have to host it yourself now, that's all.
This screen cast shows you how to do that.
So no worries if you still want to use it.
About once a month you more than make up for the $9. Very impressed good sir, very impressed. Thank you for everything!
How would I configure multiple websites on the same box? I know they would each be in a different directory by application name but how would I redirect using domain name. I know I would have to use apache virtual hosts but with Nginx I'm not sure.
Would it be better to have one IP address or multiple (looks like $1/IP on Linode).
You could check if the model exists for the current locale (I think there is a method for that - would have to look it up) and if not redirect to the existing locale. Or add a text in that case saying something like "This Article doesn't exist in your language". And then you could link to all available language versions of that article. Clicking on one of the links, will change the app to the selected locale. That is also better in terms of usability compared to fallbacks, as it's not nice to have for example a russian article appear within a layout with english texts.
Why are you not now using sprites for the area of your site shown in the video? Had to ask (practice what you preach, and all that).
What about different size of images?
It should probably be noted that at the moment there is a small glitch (regarding accessors / mass assignment) that prevents Globalize3 from working fully and seamlessly with rails 3.2.3. It will be fixed very soon, though!
Hi Ryan, would you have some nice solutions to tackle the #82 issue of ancestry? (Problem with the to_json of the arrange method)
Nice advice to put it in a initializer.
I also came across this solution a time ago. This works for some cases.
When you have a large website 10 or more locales its not handy to define a fallback for each locale. The point is you have to define the fallbacks static.
I am using an Article to explain my problem but a more suitable case is when you have an Festival. An Festival is held in a Country and has a language that is the base language for the Festival. The Festival is held in England so the organisation enters the data in the English language. The organisation decides also to translate the translate the website in the WK language. Now a German guys enters the website, what i dont want is that the website shows the Festival in the next best fallback language but the language its originally created with. Because a Festival can also be entered in the WK language(original) and English language (translation) then a German user needs to see the Festival information in WK.
Then static fallbacks wont help me..
Installing growl-notify from http://growl.info/downloads fixed the problem for me. Hope this helps.
Since you are already overwriting stuff you could try this in an initializer
Non tested and found at stackoverflow but seems like it could work. Checkout the thread to see more details
http://stackoverflow.com/questions/7942450/is-it-possible-to-make-rails-i18n-locales-fallback-to-each-other
Hello guys and Ryan,
I was having a great challenge with Globalize3 regarding translating models on a website. Globalize3 relies on models created by a base locale set by I18n.locale or config.i18n.default_locale. Now lets have this situation when video above has three locales, WK, DE and EN (EN set as default). I have my fallback set to the en locale.
When I enter articles in english all goes fine, all the entries are now English for all locales. But for example when i try to make an article in WK language only, Globalize wont fall back to that language when the user browses the English or German language. For example when I view the page in German it still falls back to the English locale which is not set. Any suggestions how to fall back to the locale in which the Model is originally created when other locales are not set?
So my goal was; when a Article is created in a locale (WK) other then the default_locale (EN), the application needs to show that locale (WK) in the article as fallback locale. Even when i enter a translation for the default locale (EN) and the user requests the page in German (DE) the article is shown in the (WK) locale.
What i did is create an base_locale attribute to the Article model and tried overriding the read_attributes globalize uses. Here is some code
This idea worked quite fine, but i had really issues with updating and generating models. Maybe someone got a better idea?
I couldn't figure out this puzzle so i stopped it 3 months ago. Since this railscast is about globalize, I thought maybe we can solve it..
Is it also possible to use realiable validations?
Thanks so much for this episode :), great stuff
Good stuff - I have the same question as this guy, regarding how to integrate ElasticSearch into a model that uses Globalize3.
We fork this gem and rewrite to more flexible globalize3
No more need to write
create_translation_table!
in migrations.Just write in AR model
translates "title:string", "content:text"
and callrake db:globalize:up
.It automatically synchronize translated columns with database (create/drop table or add/change/remove column).
What about tr8n ?
https://github.com/berk/tr8n
If you don't have a lot of languages but just two or three or so, you could keep things simpler with multiple columns in the same table. We wrote Traco for that recently, inspired by an earlier plugin called translatable_columns.
Hi Guys,
i don't really understood, how can deploy:setup successfully completed?
Because we can't create symlinks to non existing files.
Only after deploy:cold we get current folder with nginx.conf and unicorn_init.sh files.
Or I don't understand something.
At 9:49, my response.responseText contained
{"name":["can't be blank"]}
and not
{"errors": {"name":["can't be blank"]}}
(i.e. there was no "errors" key).So when parsing the messages within entries/index.js.coffee#handleError method, I did
instead of
I have rails 3.1.2, and my web browser is Chrome 16.0.912.77.
Has anyone else run into a mass assignment error when trying to create a new piano?
ActiveModel::MassAssignmentSecurity::Error in Refinery::Pianos::Admin::PianosController#create
Can't mass-assign protected attributes: name, dimensions, manufactured_on(1i), manufactured_on(2i), manufactured_on(3i), upright, photo_id, description, position
Here's screenshot of error:
http://grab.by/cWGE
If anyone has an idea how to solve this, would be appreciated.
Has anyone tried tr8n?
http://github.com/berk/tr8n
http://wiki.tr8n.org/slides
No need for YML files, full support for language context rules and language cases. Uses crowd-sourced or professional translator provided translations.
Here is what some of the translations would look like. t method is replaced with tr.
<%= tr("Hello World!") %>
<%= tr("Name:", "User name label") %>
<%= tr("You have {count|| message} in your mailbox.", nil, {count: 5}) %>
<%= tr("{actor} sent {target::dat} a message.", nil, {actor:user1, target:user2}) %>
<%= tr("{actor} sent {target::dat} [strong: {count|| message}].", nil, {actor:user1, target:user2, count:5}) %>
Michael sent Anna 5 messages.
In Russian this would need 9 translations based on the gender of actor (male, female, unknown) as well as value of count: 3 cases as well. It can translate names as well, if you so desire.
Михаил послал Анне 5 сообщений.
The technology is very powerful and has been used by Geni and Yammer and a few other companies and is now open sourced.
(Disclaimer: I am a tr8n developer)
If you try out the master branch of spree right now, you could see a vast spped boost in development because Spree now requires Rails 3.2 app.
Is there documentation on the engine generator? I was trying to lookup how I could specify a field type for uploading files instead of photos.
nm... I should look around better
http://refinerycms.com/guides/multiple-resources-in-an-extension
Ryan thanks for the excellent deployment series.
I'm attempting to deploy to Linode following these recipes and get the following error when I try to cold deploy:
Suggestions in right direction will be greatly appreciated.
Thanks a lot! Lifesaver.
Hello,
I implement Fixtures as you. But when I run rake db:seed, I meet error:
rake aborted!
uninitialized constant Fixtures
My seed.rb is:
require 'active_record/fixtures'
Fixtures.create_fixtures("#{Rails.root}/db", "categories")
My categories.yml is in db directory:
one:
name: Flying
I search on google and don't find anything. Please help me, thank you!
I have the same issue. Did you get this resolved? I can't find an indent error any where in my code.
A nice introduction done at a good pace. Content was pretty informative. Thanks Ryan!
Hey Ryan,
if you have time, it would be great if you could revise this episode!
Hey Alan,
You were correct. Originally I followed your instructions and added a "require tree ." in the last line. But for whatever reason, I left the original "require tree ." in the line above. So the problem was still there (and Stuart spotted that in his comment below).
Thanks a lot!
Sunil
Hey Stuart,
You are correct. Not sure how I missed that other "require tree ." above. Thanks a lot.
Sunil
Hi Ryan, great work on this gem!
However, how do you test it? Capybara-webkit does not seem to like it:
I see you have
require_tree .
twice in the file.You only need it once, at the bottom of the file.
Root level files get required first, if you use require_tree.
So raffler.js.coffee is getting processed before all the other files, such as the routers etc.
Ok, thanks for testing that :-)
+1
Except the server validations, I think that's pretty useful information ;)
Sorry, but calling that setup 'Very unsecure' is a big exaggeration. It is not optimal, but definitely not insecure.
The edge version of https://github.com/seyhunak/twitter-bootstrap-rails now as support for simple_form and I18n right out of the box.
The edge version of https://github.com/seyhunak/twitter-bootstrap-rails now as support for simple_form and I18n right out of the box.
Why not making this an option to the official repo ?
Thanks for this, it's so obvious! But yet I completely overlooked it! :)
Hi, it seems interesting, I'm curious about the price for the "Beginner" plan once the beta stage will end.
It would be really useful an interface for the globalize3 gem, have you planned it?
Thanks "Cailinanne"
in rails 3.2.3 you need to run your dummy server with the
rails s
command from inside the tests/dummy folder, not at the root of the engine
docs:
http://edgeguides.rubyonrails.org/engines.html