Exclude model from Railroady digram - ruby-on-rails

I am trying to create an ER diagram for my project using RailRoady. I am also using PaperTrail gem. because of this my ERD is all messed up. Is there any way to exclude PaperTrail::version table from ERD?
I went through following issue but couldn't understand much
https://github.com/preston/railroady/issues/54
and
https://github.com/preston/railroady/pull/115
Can anyone give a snippet / Example.

Stumbled across your question today and followed to that first linked issue to this comment. I'm not entirely sure how you're using RailRoady, but what worked for me looked like this:
$ railroady -M -s $picked | sed '/PaperTrail/d' > picked.dot
Here, -M signifies models specifically and -s $picked passes my own list of model files where $picked looks like this:
./app/models/my_model.rb,./app/models/another_model.rb,./app/models/a_third_model.rb
I don't think it's necessary to specify files; it's just what I was doing because I only wanted to map certain files. I then pipe it to sed, which removes lines that mention PaperTrail, before outputting it to picked.dot.
Like I said, I don't know your specific use case, but this worked for me.

Related

Can't find gtags layer default key bindings

I was trying to include the Gtags layer to make use of it in my spacemacs setup like I learned to do with vim+ctags in a given project.
Followed the instructions from: https://www.spacemacs.org/layers/+tags/gtags/README.html and included the layer in my ~/.spacemacs 'dotspacemacs-configuration-layers'. But even after restarting it I could not find the 'SPC m' key bindings to use its features.
I also tried setting (gtags :variables gtags-enable-by-default t) to have it enabled by default but apparently it did not work as well.
How do I get access to those 'SPC m' key bindings?
No 'm' option
Did not find a way to solve my gtags issue, but found another solution using etags-select.
As long as I do generate my TAGS file using the "-e" flag to be Emacs compatible, then I can navigate using tags.
cd /path/to/my/project
ctags -e -R .
It solved the my issue :)

How to generate custom URLs with Docpad?

I'm looking to remove redundant directories from my output URLs. This seems like it would be straightforward, but I can't seem to figure it out. Specifically:
This: .com/tmj/recipes/cocktails/rye/toronto.html
Should be more like this: .com/cocktails/rye/toronto.html
I've got a bit of a funny set up using a git submodule that requires the actual src documents to be organized a special way. Anyone know how I can get around this?
I was able to get the URLs I wanted by reworking the src config. This was a bit counter-intuitive to me, but now that I see it working it makes sense. Essentially I told DocPad to ignore the extra directories, and generate the site with out them. Here is the code I used, to be placed in the docpad config (docpad.coffee.)
documentsPaths: [ # default
'documents/the-mason-jar/recipes', 'pages'
]

How to get the rails.vim-command :Rview working with .js.erb-views?

I want Rview to jump to .js.erb-views as well.
It always says "Can't find file "app/views/examples/foo".
The help says:
rails-template-types
Commands like :Rview use a hardwired list of
extensions (erb, rjs, etc.) when searching for files. In order to
facilitate working with non-standard template types, several popular
extensions are featured in this list, including haml, liquid, and mab
(markaby). These extensions will disappear once a related
configuration option is added to rails.vim.
Since the view ends with .erb, i would suggest it should work.
Any Ideas?
This is strange, I just checked in my vim and it works fine. I use Janus, but I think that the standard vim + rails.vim should work well.
Maybe you need to update rails.vim?
And you can tell the sequence of your actions: the current file, typed commands, etc.

In rails.vim why do I get "E345 can't find file in path" errors?

I've been learning Ruby/Rails with vim. Tim Pope's rails.vim seems like a really good tool to traverse files with, but I keep getting these pesky "E345 can't find file in path" errors. I'm not vim expert yet, so the solution isn't obvious. Additionally, I've tried this and it doesn't apply to my problem.
As an example of the problem. I have a method format_name defined in app/helpers/application_helper.rb and it is used in app/helpers/messages_helper.rb. Within the latter file I put my cursor over the usage of format_name and then hit gf and I get that error. Similar disfunction with commands like ]f and [f
However, it works sometimes. I was able to gf from user to the app/models/user.rb
Ideas?
I think that is a limitation of rails.vim. It does not support “finding” bare methods. Supporting something like that would require one of the following:
an exhaustive search of all the source files for each “find” request
(which could be expensive with large projects),
“dumb” indexing of method names
(e.g. Exuberant Ctags and gControl-]; see :help g_CTRL-]), or
smart enough parsing of the code to make a good guess where the method might be defined
(which is hard to do properly).
If you know where the method is, you can extend many of the navigation commands with a method name:
:Rhelper application#format_name
But, you do not have to type all of that in. Assuming the cursor is on format_name you can probably just type:RhTabspaceappTab#Control-R Control-W (see :help c_CTRL-R_CTRL-W).

Examples of getting it wrong first, on purpose

I just caught myself doing something I do a lot, and wanted to generalize it, express it, share it and see who else is following this general practice, to find some other example situations where it might be relevant.
The general practice is getting something wrong first, on purpose, to establish that everything else is right before undertaking the current task.
What I was trying to do, specifically, was to find examples in our code base where the dojo TextArea widget was used. I knew (because I had it in front of me - existence proof) that the TextBox widget was present in at least one file. So I looked first for what I knew was there:
grep -r digit.form.TextBox | grep -v
svn
This wasn't right - I had made a common (for me) mistake of leaving off the star, so I fixed that:
grep -r digit.form.TextBox * | grep
-v svn
which found no results! Quick comparison with the file I was looking at showed me I had misspelled "dijit":
grep -r dijit.form.TextBox * | grep
-v svn
And now I got results. Cool; doing it wrong first on purpose meant my query was correct except for looking for the wrong thing, so now I could construct the right query:
grep -r dijit.form.TextArea * | grep
-v svn
and be confident that when it gave me no results, it was because there are no such files, and not because I had malformed the query.
I'll add three other examples as answers; please add any others you're aware of.
TDD
The red-green-refactor cycle of test-driven development may be the archetype of this practice. With red, demonstrate that the functionality doesn't exist; then make it exist and demonstrate that you've done so by witnessing the green bar.
http://support.microsoft.com/kb/275085
This VBA routine turns off the "subdatasheets" property for every table in your MS Access database. The user is instructed to make sure error-handling is set to "Break only on unhandled errors." The routine identifies tables needing the fix by the error that is thrown. I'm not sure this precisely fits your question, but it's always interesting to me that the error is being used in a non-error way.
Here's an example from VBA:
I also use camel case when I Dim my variables. ThisIsAnExampleOfCamelCase. As soon as I exit the VBA code line if Access doesn't change the lower case variable to camel case then I know I've got a typo. [OR, Option Explicit isn't set, which is the post topic.]
I also use this trick, several times an hour at least.
arrange - assert - act - assert
I sometimes like, in my tests, to add a counter-assertion before the action to show that the action is actually responsible for producing the desired outcome demonstrated by the concluding assertion.
When in doubt of my spelling, and of my editor's spell-checking
We use many editors. Many of them highlight misspelled words as I type them - some do not. I rely on automatic spell checking, but I can't always remember whether the editor of the moment has that feature. So I'll enter, say, "circuitx" and hit space. If it highlights, I'll back up over the space and the "x" and type another space - and learn that I spelled circuit correctly - but if it doesn't, I'll copy the word and paste it into a known spell-checker to see whether I did.
I'm not sure it's the best way to act, as it does not prevent you from mispelling the final command, for example typing "TestArea" or something like that instead of "TextArea" (your finger just have to slip a little for such a mistake).
IMHO the best way is to run your "final" command, but on two sample files first : one containing the requested text, another that doesn't.
In other words, instead of running a "similar" command, run the real one, but over "similar" data.
(Not sure if this would be a good idea to try for real!)
For example, you might give the system to the users for testing and tell them the password to get started is "Apple".
You know the users are fully up and ready to test (everything is installed and connections to databases working) when they contact you and say the password doesn't work (it's actually "Orange").

Resources