Git Product home page Git Product logo

Comments (9)

karimmorta avatar karimmorta commented on September 26, 2024 2

@courtsimas That's actually what I did and it's indeed super simple.
Just feels a bit awkard to include url_helpers in the model but I guess it's fine, nothing wrong with that.
The better solution is probably to use the ruby client as suggested by @robypez

Hey @ericdeansanchez, maybe I was reading the doc too fast, but I think the part about including the helpers in the model ("...This is useful for things such as including imgix URLs in JSON output from a serializer class...") should have a subtitle above it (with keywords like model, API, or something like that). I was having the impression that I couldn't use this outside of html/erb views.

๐Ÿ‘‹

from imgix-rails.

sherwinski avatar sherwinski commented on September 26, 2024 1

Hi @robypez apologies for the late response. Could you possibly provide more details as to what you're looking for? It would help me considerably in trying to provide a possible example. Thanks

from imgix-rails.

courtsimas avatar courtsimas commented on September 26, 2024 1

The documentation has no info on using these helpers or similar methods outside of the context of views. (for instance, in controllers, or in custom presenters). That would be nice to know...

UPDATE: I take that back. It's here: https://github.com/imgix/imgix-rails/blob/master/README.md#ix_image_url

from imgix-rails.

karimmorta avatar karimmorta commented on September 26, 2024 1

It could be clearer in the docs thought as this will be often used in an API context :)

from imgix-rails.

robypez avatar robypez commented on September 26, 2024 1

In the model I'm using Imgix Ruby now

from imgix-rails.

courtsimas avatar courtsimas commented on September 26, 2024 1

Canโ€™t people just extend the imgix module inside the model and use the helper just like in a view? Thatโ€™s what we do. Takes 2 seconds to do.

from imgix-rails.

robypez avatar robypez commented on September 26, 2024

Inside a model

ix_image_tag('/unsplash/hotairballoon.jpg', url_params: { w: 300, h: 500, fit: 'crop', crop: 'right'}, tag_options: { alt: 'A hot air balloon on a sunny day'

Method not found. But this works. I need to use ix_img_tag with nokogiri in my content model

include Imgix::Rails::UrlHelper

puts ix_image_url('/users/1/avatar.png', { w: 400, h: 300 })
# => https://assets.imgix.net/users/1/avatar.png?w=400&h=300

from imgix-rails.

ericdeansanchez avatar ericdeansanchez commented on September 26, 2024

Hello ๐Ÿ‘‹ @karimmorta @robypez I'd love to help here. It seems what's being asked here is better or more descriptive documentation related to use inside of models.

My question is, what kind of documentation would help in this situation? Is there a particular feature that seems to be missing or missing documentation? Is there a common task here that could be described and/or documented better?

I'm fairly new here at imgix and I'm just trying to build up a little context.

I appreciate and look forward to you feedback! :)

from imgix-rails.

ericdeansanchez avatar ericdeansanchez commented on September 26, 2024

@karimmorta Great! I am glad you've found a solution.

a subtitle above it (with keywords like model, API, or something like that). I was having the impression that I couldn't use this outside of html/erb views.

I think this could be a great addition; I will collect the context of this conversation into improved documentation + an example.

@courtsimas

Canโ€™t people just extend the imgix module inside the model and use the helper just like in a view?

Yes! :)

from imgix-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.