Ruby on Rails Thursday, August 31, 2017

Hi,

In addition to the book mentioned in this thread, this site with RailsGuides is super helpful too: http://edgeguides.rubyonrails.org/api_app.html  

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e65d2f9d-73be-4be5-b3d7-df37d9ed69a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Tuesday, August 29, 2017

This error is being raised by the has_one association between your model and the attachment record. It occurs because trying to replace the original attachment with a new one will orphan the original and cause it to fail the foreign key constraint for belongs_to associations. This is the behavior for all ActiveRecord has_one relationships (i.e. it's not specific to ActiveStorage). 

An analogous example:

class User < ActiveRecord::Base
   has_one
:profile
end
class Profile < ActiveRecord::Base
   belongs_to
:user
end

user
= User.create!
original_profile
= user.create_profile!
user
.create_profile! # attempt to replace the original profile with a new one
=> ActiveRecord::RecordNotSaved: Failed to remove the existing associated profile. The record failed to save after its foreign key was set to nil.

In attempting to create a new profile, ActiveRecord tries to set the user_id of the original profile to nil, which fails the foreign key constraint for belongs_to records. I believe this is essentially what is happening when you try and attach a new file to your model using ActiveStorage… doing so tries to nullify the foreign key of the original attachment record, which will fail. 

The solution for has_one relationships is to destroy the associated record before trying to create a new one (i.e. purging the attachment before trying to attach another one). 

Whether or not ActiveStorage should automatically purge the original record when trying to attach a new one for has_one relationships is a different question best posed to the core team…

IMO having it work consistently with all other has_one relationships makes sense, and it may be preferable to leave it up to the developer to be explicit about purging an original record before attaching a new one rather than doing it automatically (which may be a bit presumptuous).

Resources:
On Friday, August 25, 2017 at 4:51:17 AM UTC-7, Henning wrote:
We currently switched to Rails 5.2 to get the awesome functionalities of ActiveStorage.
Up until now I was able to upload, delete (purge), and show files as expected - but I am not quite sure on how to update an attachment the right way.

Here are the steps to reproduce:

user.avatar.attached?
=> false

user.avatar.attach(io: File.open("~/avatar.png"), content_type: "image/png", filename: "avatar")
=> #<ActiveStorage::Attachment id: 2, name: "avatar", record_type: "User", ...

user.avatar.attached?
=> true

user.avatar.attach(io: File.open("~/avatar2.png"), content_type: "image/png", filename: "avatar2")
=> Exception: ActiveRecord::RecordNotSaved: Failed to remove the existing associated avatar_attachment. The record failed to save after its foreign key was set to nil.

user.avatar.purge
=> nil

user.avatar.attached?
=> false

user.avatar.attach(io: File.open("~/avatar2.png"), content_type: "image/png", filename: "avatar2")
=> #<ActiveStorage::Attachment id: 2, name: "avatar2", record_type: "User", ...


I don't think it should be necessary to purge the first attachment to attach a new one. So how can this be achieved properly?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8e9ab75b-57a8-4452-a61d-532c93571e7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

You're going to have to set up some sort of script on the mail server to send the mail into your Rails app, assuming (since you didn't say so) that that's what you're trying to do. More details here: http://guides.rubyonrails.org/action_mailer_basics.html#receiving-emails

Walter

> On Aug 29, 2017, at 1:59 AM, Aqib Hameed <aqibpadana@gmail.com> wrote:
>
> I am using mailman server with pop3 configurations but i am stuck how can i check incoming email from subscribed channel ????
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/87c0ad32-2bc8-4530-a93d-c80ec08bc9bc%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0E2B6828-51B3-4140-9D2B-D8D8D61BAD06%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Monday, August 28, 2017

I am using mailman server with pop3 configurations but i am stuck how can i check incoming email from subscribed channel ????

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/87c0ad32-2bc8-4530-a93d-c80ec08bc9bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

If you have devise templates in mind (which you generate with `rails generate devise:views`), then you use Rails Internationalization API - just replace static text with #t methods, and add any missing strings to the localization file. 

On Mon, Aug 28, 2017 at 9:13 PM, fugee ohu <fugee279@gmail.com> wrote:


On Monday, August 28, 2017 at 2:06:26 PM UTC-4, Rolandas Barysas wrote:
Read Rails internationalization guide: http://guides.rubyonrails.org/i18n.html

On Mon, Aug 28, 2017 at 8:46 PM, fugee ohu <fuge...@gmail.com> wrote:
I can generate views and translations but how do i generate views with keys instead of static text? I have to edit my vies to put in the keys   manually?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9297ab97-4436-48aa-bf8a-a724051166df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Rolandas
 
Whats that have to do with devise?
 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3ce9ba68-24ad-4297-85ce-88bab2c89df0%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Rolandas

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHP7vzDpZ8Q1TSUavsbFDQRWg9CWXraa-VUyy1pnN8-wmi%2BaEA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Monday, August 28, 2017 at 2:06:26 PM UTC-4, Rolandas Barysas wrote:
Read Rails internationalization guide: http://guides.rubyonrails.org/i18n.html

On Mon, Aug 28, 2017 at 8:46 PM, fugee ohu <fuge...@gmail.com> wrote:
I can generate views and translations but how do i generate views with keys instead of static text? I have to edit my vies to put in the keys   manually?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9297ab97-4436-48aa-bf8a-a724051166df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Rolandas
 
Whats that have to do with devise?
 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3ce9ba68-24ad-4297-85ce-88bab2c89df0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Monday, August 28, 2017 at 1:46:26 PM UTC-4, fugee ohu wrote:
I can generate views and translations but how do i generate views with keys instead of static text? I have to edit my vies to put in the keys   manually?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/51956d21-afbc-4265-9686-2ca13f0501f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Read Rails internationalization guide: http://guides.rubyonrails.org/i18n.html

On Mon, Aug 28, 2017 at 8:46 PM, fugee ohu <fugee279@gmail.com> wrote:
I can generate views and translations but how do i generate views with keys instead of static text? I have to edit my vies to put in the keys   manually?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9297ab97-4436-48aa-bf8a-a724051166df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Rolandas

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHP7vzCn-mBh07tsco2uT0ss_uYixd-JWK4TTq_44T3-nfuS-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I can generate views and translations but how do i generate views with keys instead of static text? I have to edit my vies to put in the keys   manually?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9297ab97-4436-48aa-bf8a-a724051166df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Where should my devise locale files go i have devise.ch.yml in config/locales/defaults do they need to be moved up a directory What about my en.yml and ch.yml files?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/86e6215f-e5b0-4054-96fb-3eb19402fb1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Tried to add internationalization by wrapping all my routes except root with
scope "/:locale" do
...
end

That caused this error when requesting root
No route matches {:action=>"new", :controller=>"devise/sessions"} missing required keys: [:locale]

How is this supposed to work

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/bd13cf1f-133a-4b41-96b7-5c9a196cede5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Tried to add internationalization by wrapping all my routes except root with
scope "/:locale" do
...
end

That caused this error when requesting root
No route matches {:action=>"new", :controller=>"devise/sessions"} missing required keys: [:locale]

How is this supposed to work

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/42428266-8e1c-49b9-8f33-7f7db607595a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Sunday, August 27, 2017

Do you have <div class="collapse navbar-collapse" id="navbar-collapse"> element as sibling of navbar-header?

On Saturday, August 26, 2017 at 7:11:00 PM UTC+5:30, fugee ohu wrote:
   
   <div class = "navbar-header">
      <button type = "button" class = "navbar-toggle" data-toggle = "collapse" data-target = "#navbar-collapse">
      <span class = "sr-only">Toggle navigation</span>
         <span class = "icon-bar"></span>
         <span class = "icon-bar"></span>
         <span class = "icon-bar"></span>
      </button>
   </div>

Although I have this code in my view the 3 bars don't show when the screen is small


Cyber Infrastructure, [CIS] (CMMI Level 3 Company)

Central India's largest Technology Company.

Top OpenSource Agency | Microsoft Gold Partner | SAP Partner | Google Partner Agency

www.cisin.com | +Cisin | Linkedin | Offices:  India | USA | Singapore | South Africa.


*** Please note that this message and any attachments may contain confidential and proprietary material and information and are intended only for the use of the intended recipient(s). If you are not the one, you should delete it immediately to avoid any copyright issues. 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/314a5623-bede-491e-9c03-2b66161d08da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Saturday, August 26, 2017

From code you provided I assume you're using Bootstrap 3.

Do you have this inside <div class="navbar"></div> element? There's a working example in Bootstrap's documentation - https://getbootstrap.com/docs/3.3/components/#navbar.

On Sat, Aug 26, 2017 at 4:41 PM, fugee ohu <fugee279@gmail.com> wrote:
   
   <div class = "navbar-header">
      <button type = "button" class = "navbar-toggle" data-toggle = "collapse" data-target = "#navbar-collapse">
      <span class = "sr-only">Toggle navigation</span>
         <span class = "icon-bar"></span>
         <span class = "icon-bar"></span>
         <span class = "icon-bar"></span>
      </button>
   </div>

Although I have this code in my view the 3 bars don't show when the screen is small

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/30665520-8c0d-4e36-a4b8-47405af616c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Rolandas

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHP7vzCrKFEFRANPLKypPeVwjuGezirxAXgxK3DZp2rt1ny1wg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

This is not a Ruby or Rails issue, but it's your Linux distribution. You should ask your question in https://askubuntu.com/questions.
After you get this resolved, I would recommend to follow some tutorial how to correctly install Ruby and deploy your Rails application - you can google something like "deploy rails ubuntu tutorial".

Best of luck.

On Sat, Aug 26, 2017 at 4:39 PM, Aqib Hameed <aqibpadana@gmail.com> wrote:
I have a blank live server i try to install ruby 
I used this command "sudo apt-get update"
But i got an error "sudo: apt-get: command not found"
Is there is need to install Ubuntu on live server ???

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f11782fc-273d-47c0-ba39-e40e2dc84610%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Rolandas

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHP7vzCpeOw%2BfM2xT8pMLwpwp2XLMPTdfa_53MoXSQ8eULHM%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

   
   <div class = "navbar-header">
      <button type = "button" class = "navbar-toggle" data-toggle = "collapse" data-target = "#navbar-collapse">
      <span class = "sr-only">Toggle navigation</span>
         <span class = "icon-bar"></span>
         <span class = "icon-bar"></span>
         <span class = "icon-bar"></span>
      </button>
   </div>

Although I have this code in my view the 3 bars don't show when the screen is small

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/30665520-8c0d-4e36-a4b8-47405af616c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I have a blank live server i try to install ruby 
I used this command "sudo apt-get update"
But i got an error "sudo: apt-get: command not found"
Is there is need to install Ubuntu on live server ???

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f11782fc-273d-47c0-ba39-e40e2dc84610%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Friday, August 25, 2017



On Friday, August 25, 2017 at 10:30:03 AM UTC-4, Hassan Schroeder wrote:
On Fri, Aug 25, 2017 at 3:13 AM, fugee ohu <fuge...@gmail.com> wrote:

> The rails docs say i can use rb or yml but they don't say what the syntax
> for rb should be They do say rb is preferable

What doc says that? Certainly not this one:

  http://guides.rubyonrails.org/i18n.html

which also includes an example of using Ruby rather than YAML

  http://guides.rubyonrails.org/i18n.html#how-to-store-your-custom-translations

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote


http://guides.rubyonrails.org/i18n.html:

You may use YAML (.yml) or plain Ruby (.rb) files for storing your translations in SimpleStore. YAML is the preferred option among Rails developers. However, it has one big disadvantage. YAML is very sensitive to whitespace and special characters, so the application may not load your dictionary properly. Ruby files will crash your application on first request, so you may easily find what's wrong. (If you encounter any "weird issues" with YAML dictionaries, try putting the relevant portion of your dictionary into a Ruby file.)

If your translations are stored in YAML files, certain keys must be escaped. They are:

  • true, on, yes
  • false, off, no
 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/15ddbae3-28ca-48c0-9811-513d4862cca6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Fri, Aug 25, 2017 at 3:13 AM, fugee ohu <fugee279@gmail.com> wrote:

> The rails docs say i can use rb or yml but they don't say what the syntax
> for rb should be They do say rb is preferable

What doc says that? Certainly not this one:

http://guides.rubyonrails.org/i18n.html

which also includes an example of using Ruby rather than YAML

http://guides.rubyonrails.org/i18n.html#how-to-store-your-custom-translations

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yB3%3D%3Dn5GxsVcn2iF6LPs0AefqU4npKS1gEWPvDVQi9xVQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

We currently switched to Rails 5.2 to get the awesome functionalities of ActiveStorage.
Up until now I was able to upload, delete (purge), and show files as expected - but I am not quite sure on how to update an attachment the right way.

Here are the steps to reproduce:

user.avatar.attached?
=> false

user.avatar.attach(io: File.open("~/avatar.png"), content_type: "image/png", filename: "avatar")
=> #<ActiveStorage::Attachment id: 2, name: "avatar", record_type: "User", ...

user.avatar.attached?
=> true

user.avatar.attach(io: File.open("~/avatar2.png"), content_type: "image/png", filename: "avatar2")
=> Exception: ActiveRecord::RecordNotSaved: Failed to remove the existing associated avatar_attachment. The record failed to save after its foreign key was set to nil.

user.avatar.purge
=> nil

user.avatar.attached?
=> false

user.avatar.attach(io: File.open("~/avatar2.png"), content_type: "image/png", filename: "avatar2")
=> #<ActiveStorage::Attachment id: 2, name: "avatar2", record_type: "User", ...


I don't think it should be necessary to purge the first attachment to attach a new one. So how can this be achieved properly?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/54fc80a5-f136-44e8-a59d-112e15607cf4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Rails guides say this

> You may use YAML (.yml) or plain Ruby (.rb) files for storing your translations in SimpleStore

So it seems as if you just need to write a script that modifies some simple store called thing, you might try to find documentation about that.

The very same guides do also state that yaml is preferred but has downsides...


On Fr., 25. Aug. 2017, 13:26 Norbert Melzer <timmelzer@gmail.com> wrote:

So not the answer has been a bad one but your question was.

I've never used I18N and L21N in rails. So I can't help you with that.


On Fr., 25. Aug. 2017, 12:13 fugee ohu <fugee279@gmail.com> wrote:


On Friday, August 25, 2017 at 3:30:10 AM UTC-4, Norbert Melzer wrote:
fugee ohu <fuge...@gmail.com> schrieb am Fr., 25. Aug. 2017 um 09:12 Uhr:

That's not a valid answer Moderator please remove his answer


The answer that was given to you was more than valid, but you weren't able to read it correctly. The code you showed us was obviously YAML, therefore the file ending should have been yml, as pointed out. Of course, as far as I remember there are ways to use ruby files for localisation, but then you have to use ruby syntax, not YAML.

Also this is a mailinglist, and the mods do not have access to my personal mailbox, I hope at least ;) Therefore deletion is rather useless. But you are free to delete the mails you received in your personal mailbox.
 
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.

The rails docs say i can use rb or yml but they don't say what the syntax for rb should be They do say rb is preferable because it'll break with errors where yml will leave you guessing why things aren't being displayed as you expected, so I wanted to know the right rb syntax

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8c44bc48-a5a8-46db-9a16-012111163153%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2BbCVsvmrth5xfygste7VWDvtHW5iD7LDhFz42XjSz_pxbtTEw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

So not the answer has been a bad one but your question was.

I've never used I18N and L21N in rails. So I can't help you with that.


On Fr., 25. Aug. 2017, 12:13 fugee ohu <fugee279@gmail.com> wrote:


On Friday, August 25, 2017 at 3:30:10 AM UTC-4, Norbert Melzer wrote:
fugee ohu <fuge...@gmail.com> schrieb am Fr., 25. Aug. 2017 um 09:12 Uhr:

That's not a valid answer Moderator please remove his answer


The answer that was given to you was more than valid, but you weren't able to read it correctly. The code you showed us was obviously YAML, therefore the file ending should have been yml, as pointed out. Of course, as far as I remember there are ways to use ruby files for localisation, but then you have to use ruby syntax, not YAML.

Also this is a mailinglist, and the mods do not have access to my personal mailbox, I hope at least ;) Therefore deletion is rather useless. But you are free to delete the mails you received in your personal mailbox.
 
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.

The rails docs say i can use rb or yml but they don't say what the syntax for rb should be They do say rb is preferable because it'll break with errors where yml will leave you guessing why things aren't being displayed as you expected, so I wanted to know the right rb syntax

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8c44bc48-a5a8-46db-9a16-012111163153%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2BbCVsvEPP9n8J%3DTFgHasEkKCNYRKRTRh33oFp%3Drm_dTwD3%2B3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Friday, August 25, 2017 at 3:30:10 AM UTC-4, Norbert Melzer wrote:
fugee ohu <fuge...@gmail.com> schrieb am Fr., 25. Aug. 2017 um 09:12 Uhr:

That's not a valid answer Moderator please remove his answer


The answer that was given to you was more than valid, but you weren't able to read it correctly. The code you showed us was obviously YAML, therefore the file ending should have been yml, as pointed out. Of course, as far as I remember there are ways to use ruby files for localisation, but then you have to use ruby syntax, not YAML.

Also this is a mailinglist, and the mods do not have access to my personal mailbox, I hope at least ;) Therefore deletion is rather useless. But you are free to delete the mails you received in your personal mailbox.
 
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5e9d3922-0a87-4ada-a800-bc86dc60fa8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

The rails docs say i can use rb or yml but they don't say what the syntax for rb should be They do say rb is preferable because it'll break with errors where yml will leave you guessing why things aren't being displayed as you expected, so I wanted to know the right rb syntax

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8c44bc48-a5a8-46db-9a16-012111163153%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

fugee ohu <fugee279@gmail.com> schrieb am Fr., 25. Aug. 2017 um 09:12 Uhr:

That's not a valid answer Moderator please remove his answer


The answer that was given to you was more than valid, but you weren't able to read it correctly. The code you showed us was obviously YAML, therefore the file ending should have been yml, as pointed out. Of course, as far as I remember there are ways to use ruby files for localisation, but then you have to use ruby syntax, not YAML.

Also this is a mailinglist, and the mods do not have access to my personal mailbox, I hope at least ;) Therefore deletion is rather useless. But you are free to delete the mails you received in your personal mailbox.
 
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5e9d3922-0a87-4ada-a800-bc86dc60fa8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2BbCVsuXVOL9b7qf4AHSVzER%3DT-O%2Bz2NR98uOJRA2-5kQm2x0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Thursday, August 24, 2017 at 8:57:09 PM UTC-4, Antônio Augusto Sousa Britto wrote:
en.yml


2017-08-24 20:33 GMT-03:00 fugee ohu <fuge...@gmail.com>:
config/locales/en.rb

en:
   hello: "Hello world"

Rails complains unexpected : expecting end of input at the first :

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/bb956f27-c699-4039-9cea-ebc93ab6da41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


That's not a valid answer Moderator please remove his answer

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5e9d3922-0a87-4ada-a800-bc86dc60fa8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Thursday, August 24, 2017

en.yml


2017-08-24 20:33 GMT-03:00 fugee ohu <fugee279@gmail.com>:
config/locales/en.rb

en:
   hello: "Hello world"

Rails complains unexpected : expecting end of input at the first :

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/bb956f27-c699-4039-9cea-ebc93ab6da41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAK6FffJviwqrGPQj4B2xQ2ZQk50-469jBMNviBQa%3DxY26ZuhwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

config/locales/en.rb

en:
   hello: "Hello world"

Rails complains unexpected : expecting end of input at the first :

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/bb956f27-c699-4039-9cea-ebc93ab6da41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi everyone,    I am happy to announce that Rails 5.0.6.rc1 and 5.1.4.rc1 have been released.    If no regressions are found, expect the final release on Tuesday, August 29, 2017.  If you find one, please open an [issue on GitHub](https://github.com/rails/rails/issues/new)  and mention me (@eileencodes) on it, so that we can fix it before the final release.    ## CHANGES since 5.0.5    To view the changes for each gem, please read the changelogs on GitHub:      * [Action Cable CHANGELOG](https://github.com/rails/rails/blob/v5.0.6.rc1/actioncable/CHANGELOG.md)    * [Action Mailer CHANGELOG](https://github.com/rails/rails/blob/v5.0.6.rc1/actionmailer/CHANGELOG.md)    * [Action Pack CHANGELOG](https://github.com/rails/rails/blob/v5.0.6.rc1/actionpack/CHANGELOG.md)    * [Action View CHANGELOG](https://github.com/rails/rails/blob/v5.0.6.rc1/actionview/CHANGELOG.md)    * [Active Job CHANGELOG](https://github.com/rails/rails/blob/v5.0.6.rc1/activejob/CHANGELOG.md)    * [Active Model CHANGELOG](https://github.com/rails/rails/blob/v5.0.6.rc1/activemodel/CHANGELOG.md)    * [Active Record CHANGELOG](https://github.com/rails/rails/blob/v5.0.6.rc1/activerecord/CHANGELOG.md)    * [Active Support CHANGELOG](https://github.com/rails/rails/blob/v5.0.6.rc1/activesupport/CHANGELOG.md)    * [Railties CHANGELOG](https://github.com/rails/rails/blob/v5.0.6.rc1/railties/CHANGELOG.md)      *Full listing*    To see the full list of changes, [check out all the commits on  GitHub](https://github.com/rails/rails/compare/v5.0.5...v5.0.6.rc1).      ## CHANGES since 5.1.3    To view the changes for each gem, please read the changelogs on GitHub:      * [Action Cable CHANGELOG](https://github.com/rails/rails/blob/v5.1.4.rc1/actioncable/CHANGELOG.md)    * [Action Mailer CHANGELOG](https://github.com/rails/rails/blob/v5.1.4.rc1/actionmailer/CHANGELOG.md)    * [Action Pack CHANGELOG](https://github.com/rails/rails/blob/v5.1.4.rc1/actionpack/CHANGELOG.md)    * [Action View CHANGELOG](https://github.com/rails/rails/blob/v5.1.4.rc1/actionview/CHANGELOG.md)    * [Active Job CHANGELOG](https://github.com/rails/rails/blob/v5.1.4.rc1/activejob/CHANGELOG.md)    * [Active Model CHANGELOG](https://github.com/rails/rails/blob/v5.1.4.rc1/activemodel/CHANGELOG.md)    * [Active Record CHANGELOG](https://github.com/rails/rails/blob/v5.1.4.rc1/activerecord/CHANGELOG.md)    * [Active Support CHANGELOG](https://github.com/rails/rails/blob/v5.1.4.rc1/activesupport/CHANGELOG.md)    * [Railties CHANGELOG](https://github.com/rails/rails/blob/v5.1.4.rc1/railties/CHANGELOG.md)      *Full listing*    To see the full list of changes, [check out all the commits on  GitHub](https://github.com/rails/rails/compare/v5.1.3...v5.1.4.rc1).      ## SHA-256    If you'd like to verify that your gem is the same as the one I've uploaded,  please use these SHA-256 hashes.    Here are the checksums for 5.0.6.rc1:    ```  $ shasum -a 256 *-5.0.6.rc1.gem  0490ac6c4621756871839ad584f0a0349a72a9ccdeac0f72dafd3539638ba5ef  actioncable-5.0.6.rc1.gem  fc7697724d884307bf2ea307c028902f71f96304b9a882418e6ec94d10202cd9  actionmailer-5.0.6.rc1.gem  b0f1f4479f61ada80b3dbe3e9ccaa0db390119918e5da632dda3c8398e6e4f5f  actionpack-5.0.6.rc1.gem  673d06523edf733163ad668fe3cd64bd1c7fb97244c952241d1e00ee6835101b  actionview-5.0.6.rc1.gem  ac6521d4df459db19fc0f2740d0e0c0a6f3102252c8124ecb25e8d33335d6cf4  activejob-5.0.6.rc1.gem  0824cd58f175a3c825dce9d42d73254d25af25d824ae1c5c3465f12bb0812f72  activemodel-5.0.6.rc1.gem  7972a8a76c711b8fc01ab52d95c4f16a73e9683e4d745a17d61ab91051df856c  activerecord-5.0.6.rc1.gem  40f0c77de7e54b6a3581272ce5b6409ae0c61b5bfad3239db46807d8342ce8a3  activesupport-5.0.6.rc1.gem  7873311d5340bffbabeb33cb9d3ce2c97056bc2bebad3abfcba6f5b38b209075  rails-5.0.6.rc1.gem  3fd4b347f19fb4ff2ec7cee4c9a45aba31d1e287583943269bc9d09bef61ca93  railties-5.0.6.rc1.gem  ```    Here are the checksums for 5.1.4.rc1:    ```  $ shasum -a 256 *-5.1.4.rc1.gem  6ebb05e31a5d46379f638092742aa1543ab3522302a62351de9e5dc746fc7c77  actioncable-5.1.4.rc1.gem  fb3e3743a29a70524c64caa656056f7cf0085998a1438b28325c6e10a6330efd  actionmailer-5.1.4.rc1.gem  c4b39e9b721a4b2eb37be9f18bfbc0a479b61ae4d6b536b1b9f2fc06f83f6ad8  actionpack-5.1.4.rc1.gem  9930cccacbe71085b894ca0410da07625b801c4db1775b655357bd2bf5824ae9  actionview-5.1.4.rc1.gem  e0c7610f4fe20c778e5f9739f80ae4d5d3450bbacff49d24064b0b3b048f9dd6  activejob-5.1.4.rc1.gem  11dae082bd1dfea9541a60501135bef6c32d792407dea57250dc95ba5e415a77  activemodel-5.1.4.rc1.gem  3b058a80c8f14c324dad4c185825a4ce4c4f853af37002bec92e179bef583fcb  activerecord-5.1.4.rc1.gem  c9984249c0200e9c1f462779294e0cec6bb6c8b95421dc01b579a0efa2db6561  activesupport-5.1.4.rc1.gem  c8134e1efcc5f17ac28927a76423146f3a7baf618d97a5d752d09edf4c5eeb7c  rails-5.1.4.rc1.gem  7589a79f6b4a4de73d2d427193eb9beacd1628530958dd4d8f9404531748a973  railties-5.1.4.rc1.gem  ```    As always, huge thanks to the many contributors who helped with this release!

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/556dc9cf-6f18-4ad3-b591-ef3aabd89c5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

To those who are joining the project you are very much welcome in the group. Just go to the link I added above and let's all have fun coding time :)

On Thursday, August 24, 2017 at 6:18:57 PM UTC+8, Norman Santiago wrote:
Hi I would like to invite every one on participating in my open source project( pls see the link below ). It is a LMS project that has a vision to improve the teaching strategies of instructors but at the same time concerned on how to help the students on their learning methods. If ever you have a question or a suggestion regarding the project just let me know so that we could discussion about it. Thanks


ps. also as you can see the projects name is too generic and long, if ever you have a good suggestion then talk to me so that we can have it in a list and have a vote which one is better.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6253ffe0-0b0a-4b09-9a73-5ae934e62005%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.