0

I'm trying to create hash values to use in a for loop in my view. But for some reason, creating these hash's pretty much breaks the whole site, no matter where I put them.

CRF_PATH = {Baseline => baseline_path, FollowUp3Week => follow_up3_week_path, TreatmentCompletion => treatment_completion_path, FollowUp18Week => follow_up18_week_path, FollowUp6Month => follow_up6_month_path, PsychosocialScale => psychosocial_scale_path}

Where should I define this hash, and am I defining it incorrectly?

Thank you for your time.

Edit. Removed unnecessary and unrelated info.

Ian Ellis
  • 541
  • 6
  • 19
  • Possible duplicate of [What is the best way to handle constants in Ruby when using Rails?](http://stackoverflow.com/questions/265725/what-is-the-best-way-to-handle-constants-in-ruby-when-using-rails) – rails_id Sep 08 '16 at 01:48
  • It might help us to see the output of `p CRFS_TO_VIEW`. It's really not clear at all what you have, what you want to do, or what your attempted solution is. – mwp Sep 08 '16 at 02:18

1 Answers1

1

Let's take a quick peek at the start of the hash definition:

CRF_PATH = {Baseline => baseline_path

Baseline is being evaluated as a class name. Do you have a class named Baseline? If not, what do you intend this key to be? A string, a symbol, something else?

baseline_path is being evaluated as a local variable or a method name. Do you have a method named baseline_path? If not, what do you intend this key to be? A string, a symbol, or something else?

mwp
  • 8,217
  • 20
  • 26
  • I updated my post in hope that you can see what I'm going for. I did not know that baseline was being evaluated that way, but I can see that now. I'm using this array so that it can replace the 'path' portion of a link to a record. The in the case you mentioned, baseline_path is supposed to be a string that is then appended to the link_to item. – Ian Ellis Sep 08 '16 at 02:04
  • @IanEllis If you have strings, you should quote them, with `'` or `"`. – mwp Sep 08 '16 at 02:17
  • 1
    Thanks! That was the problem. Not to say I got it working, but that was exactly why it was all breaking. Thanks again. – Ian Ellis Sep 08 '16 at 02:31
  • @IanEllis Oh, great! Happy I could help. – mwp Sep 08 '16 at 03:38