Max Williams
2009-Apr-21 13:58 UTC
backup (*~) view files are being used instead of proper view
This is a weird one. I just started making a new app, and have noticed a weird problem: I do my editing in gedit in linux, which saves backup files as ''<filename>~'', eg "index.html.erb~" for a view template. I''m running mongrel, and when i refresh a page it''s loading the backup view file in preference to the ''proper'' file! If there''s no backup then it loads the proper file. I can''t work out why it''s doing this - does anyone have any ideas? thanks max -- Posted via http://www.ruby-forum.com/.
Max Williams
2009-Apr-22 09:11 UTC
Re: backup (*~) view files are being used instead of proper view
SOLVED - I upgraded to rails 2.3.2 (this problem was happening for me in 2.3.0) and the problem went away. It was definitely a problem with rails because i made a new app and it had the same problem, which also went away when i upgraded rails. So, it seems that rails 2.3.0 prefers view files ending in ''.html.erb~'' to ones that end in ''html.erb''. Something to watch out for. I''m still curious as to why it was doing that, if anyone knows, and how to tell it not to (in case it starts happening again). -- Posted via http://www.ruby-forum.com/.
Brendon
2009-Apr-23 00:38 UTC
Re: backup (*~) view files are being used instead of proper view
It''s related to how Rails is compiling templates. It *more or less* ignores the extensions and compiles all the files in all directories under the app/view. It can also bite you if you rename a file to move it out to keep an original version while trying something or if you have a straight html version of the file. I''d suggest that you make sure you don''t leave more than one view file with the same base name. (i.e. if you try a haml version, rename the html.erb version.) Remember this if you see a problem... else you would have to fix it by overriding some core rails template code, which is a step on the road to hurt! Brendon On Apr 22, 2:11 am, Max Williams <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> SOLVED - I upgraded to rails 2.3.2 (this problem was happening for me in > 2.3.0) and the problem went away. It was definitely a problem with > rails because i made a new app and it had the same problem, which also > went away when i upgraded rails. > > So, it seems that rails 2.3.0 prefers view files ending in ''.html.erb~'' > to ones that end in ''html.erb''. Something to watch out for. I''m still > curious as to why it was doing that, if anyone knows, and how to tell it > not to (in case it starts happening again). > -- > Posted viahttp://www.ruby-forum.com/.
Max Williams
2009-Apr-23 07:22 UTC
Re: backup (*~) view files are being used instead of proper view
HI brendon, thanks for answering. I never saw this before v2.3.0 and it''s gone now that i upgraded again to 2.3.2. Your answer suggests that it''s a natural behaviour of rails that one has to bear in mind, i''d disagree, it seems like a flat out bug. In order to ''cure'' it without upgrading i''d have to use a different text editor, or set it to not make backups. This isn''t really acceptable to me. I''m not an authority on rails though, i''d be interested to know what others think. Is it a bug? or should i just keep backup files out of my view folders? (in the hypothetical situation where i was forced to use v2.3.0) -- Posted via http://www.ruby-forum.com/.
Frederick Cheung
2009-Apr-23 08:08 UTC
Re: backup (*~) view files are being used instead of proper view
On Apr 23, 8:22 am, Max Williams <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> HI brendon, thanks for answering. > I''m not an authority on rails though, i''d be > interested to know what others think. Is it a bug? or should i just > keep backup files out of my view folders? (in the hypothetical > situation where i was forced to use v2.3.0)2.3.0 was a release candidate - if you''re forced to use it something is screwed up. Fred> -- > Posted viahttp://www.ruby-forum.com/.
Max Williams
2009-Apr-23 08:33 UTC
Re: backup (*~) view files are being used instead of proper view
Hi Frederick I''m not forced to use it at all, i already said i upgraded to 2.3.2. :) I was just wondering about the hypothetical situation (in some parallel world) where i''m stuck using it and can''t just run away from this problem (like i did do by upgrading). -- Posted via http://www.ruby-forum.com/.
Colin Law
2009-Apr-23 08:55 UTC
Re: backup (*~) view files are being used instead of proper view
I may be talking rubbish here but I think when using a framework such as Rails it might be considered bad practice to save backups in the project directory structure. In Rails the presence of a file is meaningful. For example it is not necessary to declare that a controller exists, if it is present in the controllers directory then that controller exists. As a general principle then it could be argued that superfluous files should not be saved in the project, just in case. In addition many would argue that a version control system such as git should be used, with commits to the local repository at every opportunity, and therefore backups are not necessary at all. 2009/4/23 Max Williams <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>> > Hi Frederick > > I''m not forced to use it at all, i already said i upgraded to 2.3.2. :) > > I was just wondering about the hypothetical situation (in some parallel > world) where i''m stuck using it and can''t just run away from this > problem (like i did do by upgrading). > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Max Williams
2009-Apr-23 09:21 UTC
Re: backup (*~) view files are being used instead of proper view
Colin Law wrote:> I may be talking rubbish here but I think when using a framework such as > Rails it might be considered bad practice to save backups in the project > directory structure. In Rails the presence of a file is meaningful. > For > example it is not necessary to declare that a controller exists, if it > is > present in the controllers directory then that controller exists. As a > general principle then it could be argued that superfluous files should > not > be saved in the project, just in case. > > In addition many would argue that a version control system such as git > should be used, with commits to the local repository at every > opportunity, > and therefore backups are not necessary at all. > > 2009/4/23 Max Williams <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Yeah, tbh i think you''re probably right. I should just tell gedit to stop making backups, i very *very* rarely ever use them. I already had to tell git to ignore them and occasionally one manages to slip through anyway, not great. -- Posted via http://www.ruby-forum.com/.
Brendon
2009-Apr-23 19:52 UTC
Re: backup (*~) view files are being used instead of proper view
I''d say that is rubbish, since many editors create backup files, swap files and other junk following some pretty well defined conventions. Rails template compile code is very greedy and doesn''t care much about extensions, even extensions it doesn''t understand. That is the bug. Rails should not be the first application to completely ignore file extensions and equate foo.html, foo.txt, foo.backup, foo.html.erb, foo.rjs, foo.haml, foo.rhtml and foo.moved_out_the_way.html.erb as all being equivalent... As a general principle, source control systems ignore these files and so should rails. You are proposing that anything in the file tree is 100% fair game for Rails which would require many normal development activities to be modified in inconvenient ways... On Apr 23, 1:55 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> I may be talking rubbish here but I think when using a framework such as > Rails it might be considered bad practice to save backups in the project > directory structure. In Rails the presence of a file is meaningful. For > example it is not necessary to declare that a controller exists, if it is > present in the controllers directory then that controller exists. As a > general principle then it could be argued that superfluous files should not > be saved in the project, just in case. > > In addition many would argue that a version control system such as git > should be used, with commits to the local repository at every opportunity, > and therefore backups are not necessary at all. >
Colin Law
2009-Apr-23 20:10 UTC
Re: backup (*~) view files are being used instead of proper view
2009/4/23 Brendon <brendon-gi94QSVkwfGt/hvpvFFPbQ@public.gmane.org>> > I''d say that is rubbish, since many editors create backup files, swap > files and other junk following some pretty well defined conventions. > Rails template compile code is very greedy and doesn''t care much about > extensions, even extensions it doesn''t understand. That is the bug. > Rails should not be the first application to completely ignore file > extensions and equate foo.html, foo.txt, foo.backup, foo.html.erb, > foo.rjs, foo.haml, foo.rhtml and foo.moved_out_the_way.html.erb as all > being equivalent... > > As a general principle, source control systems ignore these files and > so should rails. You are proposing that anything in the file tree is > 100% fair game for Rails which would require many normal development > activities to be modified in inconvenient ways... >I was not suggesting that this is not a deficiency in Rails (I leave that discussion to others). I was suggesting that by not saving extraneous files in the project then the issue could be avoided. That is not rubbish, it is defensive programming.> > On Apr 23, 1:55 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > I may be talking rubbish here but I think when using a framework such as > > Rails it might be considered bad practice to save backups in the project > > directory structure. In Rails the presence of a file is meaningful. For > > example it is not necessary to declare that a controller exists, if it is > > present in the controllers directory then that controller exists. As a > > general principle then it could be argued that superfluous files should > not > > be saved in the project, just in case. > > > > In addition many would argue that a version control system such as git > > should be used, with commits to the local repository at every > opportunity, > > and therefore backups are not necessary at all. > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---