snowangel
snowangel

Reputation: 3462

hyphen in API params

The answer to this question specifically mentions using the params [:body-plain]. However, Rails throws this error: NameError (undefined local variable or method 'plain' for #<IncomingMailsController:0x0000000913f278>):

How can I access params that have a hyphen in? I can't change the params as they're posted from a third party API (Mailgun).

Upvotes: 4

Views: 1406

Answers (1)

Maur&#237;cio Linhares
Maur&#237;cio Linhares

Reputation: 40333

You need to access them like this:

params[:'body-plain']

Or even just like this:

params["body-plain"]

You have to escape your symbol name if it contains special characters.

Upvotes: 11

Related Questions