Giter Club home page Giter Club logo

Comments (15)

rogercampos avatar rogercampos commented on July 3, 2024

Hi, thanks for your comments. I think it's usually best to let the developer handle how to display things and not give anything done by default. As you say, it can be done using the 'dispolay_as' feature, even though I may agree with you that this can be a little hard to do for a new rails developer. Maybe a better docs or a wiki page talking about this could help.

About adding an option to do it, I rather think that it might be more useful to add a new feature to make 'display_as' work with a helper method directly. People usually use this feature as a bridge to some other rails helper method, like number_to_currency or simple_format, so maybe provide a direct way to implement this could be a better solution.

About your note about the text beeing displayed without format during the ajax request you're right, we'll look into it and thanks for the catch!

from best_in_place.

rogercampos avatar rogercampos commented on July 3, 2024

Hi, I've just implemented a new feature display_with which provides direct bindings for view helpers. You can use it like this:

= best_in_place @user, :large_comment, :display_with => :simple_format

from best_in_place.

brianmaissy avatar brianmaissy commented on July 3, 2024

When I do this:
best_in_place user, :notes, :type => :textarea, :display_with => :simple_format
I get this error:
undefined method 'white_list_sanitizer' for Module:Class
Am I using it wrong? I googled the error but the solutions didn't work. "Module:Class" is throwing me off. It's almost as if the helper is being called in the wrong context or on the wrong object?

from best_in_place.

tbuyle avatar tbuyle commented on July 3, 2024

Same error here.

from best_in_place.

edwallitt avatar edwallitt commented on July 3, 2024

and me too!

from best_in_place.

tbuyle avatar tbuyle commented on July 3, 2024

Added as a new issue : #78

from best_in_place.

albertbellonch avatar albertbellonch commented on July 3, 2024

Hi all,

This issue is now solved with pull request #79.

You can checkout Rails Action View's SanitizeHelper, which includes sanitize(html, options = {}) (the method that ended up breaking), called from our old friend TextHelper's simple_format(text, html_options={}, options={}).

After some investigation, I realized that SanitizeHelper's white_list_sanitizer should always be initialized (check out this). But it wasn't! Was Ruby falling apart or something...?

The answer is no. The problem is that we used Action View's Helpers in the non-right way, without loading every single Helper as we should do. In our previous approach, the ClassMethods weren't correctly load, so our dear white_list_sanitizer wasn't initialized when accessed, and thus our call to simple_format was broken.

Now we are using an instance of ActionView::Base, so everything is loaded in a more right way, and everything keeps being as simple as always.

More insight can be found in here and here.

from best_in_place.

cmbankester avatar cmbankester commented on July 3, 2024

I still get this issue when doing, for example,
best_in_place(model, :chart, type: :textarea, nil: 'Click to edit your chart', display_with: :simple_format).
The error I get is this:
undefined method white_list_sanitizer' for Module:Class`.
Also, I am using decorators a la Draper.

from best_in_place.

albertbellonch avatar albertbellonch commented on July 3, 2024

Hello @cbanke1

Which best_in_place are you using? This fix is not yet in any version of the gem, so if you want to use it you have to use the gem directly from the git repository.

We are planning to do a release (which will be 1.0.5) in less than two weeks.

Did it fix the issue?

from best_in_place.

cmbankester avatar cmbankester commented on July 3, 2024

@albertbellonch
No, I do not believe. I have it set in the gemfile as such:
gem 'best_in_place', git: "https://github.com/bernat/best_in_place.git"
but I still get the undefined method white_list_sanitizer exception.

Should I also specify a commit? It seems like pulling from github should pull the most recent master.

UPDATE: I think I fixed the issue, which was local. I'll come back if I have more information. Thanks for all your help!

from best_in_place.

diffractometer avatar diffractometer commented on July 3, 2024

Me 2

from best_in_place.

markmilman avatar markmilman commented on July 3, 2024

same here

from best_in_place.

Akshg avatar Akshg commented on July 3, 2024

I am using display_with: :simple_format. Its working fine. But then, the text does not remain editable at all.
I tried fetching directly from git repo, but it doesn't help. Any input will be helpful.
Thanks.

from best_in_place.

cg5544 avatar cg5544 commented on July 3, 2024

@Akshg I am running into the sample issue. :simple_format works but text is not editable anymore.

from best_in_place.

Akshg avatar Akshg commented on July 3, 2024

@cg5544 Even i was am facing the same issue at that time. Any progress?

from best_in_place.

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.