Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add arbitrary static text to node data via template #34

Closed
marccantwell opened this issue Aug 22, 2011 · 4 comments
Closed

add arbitrary static text to node data via template #34

marccantwell opened this issue Aug 22, 2011 · 4 comments

Comments

@marccantwell
Copy link

Is it possible to add some arbitrary static text to the actual node data, basically concatenating the content. for example:

template
api_accessible :payment_chart_data do |template|
template.add :month_due
template.add :count
end

The original template:
{"rows":[{"month_due":"(2010, 02)","count":"1"}}

With static text added:
{"rows":[{"month_due":"Date.UTC(2010, 02)","count":"1"}

@fabrik42
Copy link
Owner

Hi Marc,

I think a proper solution would be to do this extra formatting in an extra method.

For example:

class MyModel < ActiveRecord::Base

  api_accessible :payment_chart_data do |template|
    template.add :month_due_formatted, :as => :month_due
    template.add :count
  end

  def month_due_formatted
    "Date.UTC#{month_due}"
  end

end

@fabrik42
Copy link
Owner

Closing this for now. If you need further help, just let me know :)

@marccantwell
Copy link
Author

Sorry, just got back from vacation. Thanks so much for the help. This is a fantastic gem and your timely response was very much appreciated. Thanks again.

@fabrik42
Copy link
Owner

Thanks and you are very welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants